Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/siiky/ipfs.lua
[MOVED] Client for the Kubo RPC API
https://github.com/siiky/ipfs.lua
ipfs ipfs-api kubo lua
Last synced: 3 months ago
JSON representation
[MOVED] Client for the Kubo RPC API
- Host: GitHub
- URL: https://github.com/siiky/ipfs.lua
- Owner: siiky
- License: unlicense
- Archived: true
- Created: 2022-05-02T00:10:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-09T19:25:40.000Z (11 months ago)
- Last Synced: 2024-09-18T02:13:25.680Z (3 months ago)
- Topics: ipfs, ipfs-api, kubo, lua
- Language: Lua
- Homepage: https://git.sr.ht/~siiky/ipfs.lua
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ipfs.lua
**Lua library for the [Kubo] [RPC API], the reference [IPFS] node
implementation.**Endpoint definitions (`ipfs-enpoints.lua`) are generated with
`export-to-lua.scm` from [`ipfs.scm`].---
Most of the requirements for [`ipfs.scm`] also apply here. You must be familiar
with the IPFS HTTP API if you want to use this library. It tries to catch some
bad usage but it's not very strict.Each exported procedure represents one endpoint -- see the note on [`ipfs.scm`]
about missing endpoints. In general, `/api/v0/some/endpoint` will be used as
`ipfs:some_endpoint` -- more specifically, `[-/]` are replaced with `_` to make
the endpoint name a valid Lua identifier. For example, `id` is called `id`,
`bootstrap/list` is called `bootstrap_list`, and `diag/cmds/set-time` is called
`diag_cmds_set_time`.The `reader`, `writer`, and `timeout` may all be overwritten on a per-call
basis.## Usage
```lua
-- There are some "module parameters":
local IPFS = require('ipfs')({
-- Both readers are optional. If not given, none will be used and you must
-- manually "read" the HTTP stream.
reader_json=...,
reader_plain=...,
})-- And "instance parameters":
local ipfs = IPFS({
-- The connection details and their defaults:
scheme='http',
host="localhost",
port=5001,-- Optionally (see the http rock):
timeout=...,
})-- OR:
--[[
local ipfs = require('ipfs')({
reader_json=...,
reader_plain=...,
})({
scheme='http',
host="localhost",
port=5001,
timeout=...,
})
--]]-- No arguments, parameters, nor options given. Calls the `/api/v0/id`
-- endpoint with the default reader, writer, and timeout.
ipfs:id()-- The recognized options are `reader`, `writer`, and `timeout`.
ipfs:id(nil, {}, {reader=..., writer=..., timeout=...})-- The reader may be skipped on a per-call basis if given and truthy but not a
-- procedure.
ipfs:id({}, nil, {reader=true})-- Unexpected arguments/parameters, i.e., arguments/parameters that are no
-- specified in the endpoint's definition, are ignored.
ipfs:id({1, 2, 3}, {another="thing"})
```Also check out `example.lua`.
[IPFS]: https://ipfs.io
[Kubo]: https://github.com/ipfs/kubo
[RPC API]: https://docs.ipfs.io/reference/kubo/rpc
[`ipfs.scm`]: https://git.sr.ht/~siiky/ipfs.scm