Unofficial SDK for [Pinata](https://pinata.cloud), implemented in ReasonML and compiled to Javascript.
npm install pinata-sdkUnofficial SDK for Pinata, implemented in ReasonML and compiled to Javascript.
In order to use some of the SDK's features, you'll have to sign up with Pinata to obtain your API keys. To learn more about Pinata check out the getting started guide.
Install the package - it includes both the javascript & reason versions.
```
npm i --save pinata-sdk
If you're using ReasonML, add this to your bsconfig.json:`javascript`
"bs-dependencies": [
"pinata-sdk"
],
> ⚠️ For usage with Node.js, make sure to include the node-fetch polyfill.
`ocaml
open PinataSdk;
open PinataSdk.PinHashToIPFS;
let hash = "
let apiKey = "
let privateApiKey = "
let pinata = Pinata.configure(
~apiKey = apiKey,
~privateApiKey = privateApiKey,
()
);
pinata
->Pinata.pinHashToIPFS(~hash=hash)
|> then_(result => {
Js.log("Content pinned successfully" ++ result->ipfsHashGet)
Js.Promise.resolve(result);
})
`
`typescript
import * as Pinata from 'pinata-sdk';
const apiKey = "
const privateApiKey = "
const hash = "
const pinata: Pinata.PinataConfig = Pinata.configure(apiKey, privateApiKey);
(async function() {
try {
const result: Pinata.PinHashToIPFSResponseJS = await Pinata.pinHashToIPFS(
pinata,
hash
);
console.log("Content pinned successfully", result.ipfsHash);
} catch (err) {
console.error("Content was not pinned", err);
}
})();
`
`javascript
const Pinata = require('pinata-sdk');
const apiKey = "
const privateApiKey = "
const hash = "
const pinata = Pinata.configure(apiKey, privateApiKey);
(async function() {
try {
const result = await Pinata.pinHashToIPFS(
pinata,
hash
);
console.log("Content pinned successfully", result.ipfsHash);
} catch (err) {
console.error("Content was not pinned", err);
}
})();
`
Available methods of the SDK, for usage examples see the quick start guide or the examples section.
##### configure (~apiKey: string, ~privateApiKey: string, ~apiURL: string = apiURL): pinataConfig
- apiKey your api key from pinataprivateApiKey
- your private api key from pinataapiURL
- optional, default value https://api.pinata.cloud
##### pinHashToIPFS (config: pinataConfig, ~hash: ipfsHash): Promise.t(pinHashToIPFSResponseJS)
- config SDK configuration created via configure()hash
- IPFS content hash to be pinned
You can find the usage examples in the examples folder.
> 🐳 Optionally you can start the development container described in the contributing section, in order to run the examples smoothly.
Make sure to:
1. npm i before running each example.examples/**/credentials.js
2. Update your Pinata API credentials in
3. Update the IPFS hash you want to pin - usually a string in the example's source files.
Each example can be run using npm start.
Some examples might contain additional README.md to help you understand the details.
PinataSDK is developed & built trough docker, to start contributing, you'll have to setup docker for your platform first.
> Editor support for ReasonML works well with VSCode's OCaml and Reason IDE
Everything you need to contribute to PinataSDK happens inside the development container
`bash`Build an image for our dev container
make build-imageLaunch the container with an interactive bash session
make bash
List of available commands can be found in package.json.
`bashInstall dependencies
npm install
PinataSDK is available under the MIT License

Pinata SDK is created and maintained by Matej Sima.
Special thanks to the Pinata team for such an awesome service!