Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<a href="#getting-started">Getting started</a> •
<a href="#installation">Installation</a> •
<a href="#usage">Usage</a> •
<a href="https://github.com/blockfrost/blockfrost-js-examples" target="_blank">Examples</a> •
<a href="https://github.com/blockfrost/blockfrost-js/wiki/Exports">SDK API Reference</a>
<a href="https://github.com/blockfrost/blockfrost-js-examples" target="_blank">Examples</a>
</p>
<br>

Expand Down Expand Up @@ -45,8 +44,6 @@ yarn add @blockfrost/blockfrost-js
Using the SDK is pretty straight-forward as you can see from the following examples.
For more examples take a look in [blockfrost-js-examples](https://github.com/blockfrost/blockfrost-js-examples) repository.

For a list of all SDK methods [check out our wiki](https://github.com/blockfrost/blockfrost-js/wiki/Exports).

```ts
const Blockfrost = require('@blockfrost/blockfrost-js');
// import { BlockFrostAPI } from '@blockfrost/blockfrost-js'; // using import syntax
Expand All @@ -69,6 +66,35 @@ const API = new Blockfrost.BlockFrostAPI({
- `version` - `number`, version of the Blockfrost API (optional, default `0`)
- `gotOptions` - Additional options to be passed to Got instance. For more details, refer to the [Got Options documentation](https://github.com/sindresorhus/got/blob/main/documentation/2-options.md).

### Rate limiter

The built-in rate limiter is powered by [Bottleneck](https://www.npmjs.com/package/bottleneck). The underlying Bottleneck instance is exposed as `rateLimiter` property on the API client (it is `undefined` if the rate limiter was disabled via options), allowing you to inspect the current queue or hook into its events.

```ts
const Blockfrost = require('@blockfrost/blockfrost-js');

const API = new Blockfrost.BlockFrostAPI({
projectId: 'YOUR API KEY HERE', // see: https://blockfrost.io
});

// inspect the current queue
// returns counts of jobs in each state, e.g. { RECEIVED: 0, QUEUED: 0, RUNNING: 0, EXECUTING: 0 }
console.log(API.rateLimiter?.counts());

// number of requests waiting in the queue
console.log(API.rateLimiter?.queued());

// remaining request capacity before the limiter starts queuing new requests
const reservoir = await API.rateLimiter?.currentReservoir();
console.log(reservoir);

// get notified when the request capacity is depleted and requests start queuing up
API.rateLimiter?.on('depleted', () => {
console.log('Rate limit reached, new requests will be queued.');
});
```

For a full list of available methods and events check out the [Bottleneck documentation](https://www.npmjs.com/package/bottleneck).

## Error handling

Expand Down Expand Up @@ -135,8 +161,6 @@ try {

For more examples take a look in [blockfrost-js-examples](https://github.com/blockfrost/blockfrost-js-examples) repository.

For a list of all SDK methods [check out our wiki](https://github.com/blockfrost/blockfrost-js/wiki/Exports).

### Cardano

```typescript
Expand Down Expand Up @@ -201,10 +225,10 @@ runExample();

Blockfrost SDK exports several utility functions to improve developer experience.

- [deriveAddress](https://github.com/blockfrost/blockfrost-js/wiki/Exports#deriveaddress)
- [getFingerprint](https://github.com/blockfrost/blockfrost-js/wiki/Exports#getfingerprint)
- [parseAsset](https://github.com/blockfrost/blockfrost-js/wiki/Exports#parseasset)
- [verifyWebhookSignature](https://github.com/blockfrost/blockfrost-js/wiki/Exports#verifywebhooksignature)
- [deriveAddress](https://github.com/blockfrost/blockfrost-js/blob/master/src/utils/helpers.ts)
- [getFingerprint](https://github.com/blockfrost/blockfrost-js/blob/master/src/utils/helpers.ts)
- [parseAsset](https://github.com/blockfrost/blockfrost-js/blob/master/src/utils/helpers.ts)
- [verifyWebhookSignature](https://github.com/blockfrost/blockfrost-js/blob/master/src/utils/helpers.ts)

## Development

Expand All @@ -215,6 +239,3 @@ Blockfrost SDK exports several utility functions to improve developer experience
- update [TSDoc](https://tsdoc.org/) for added method
2. Add class method to `BlockfrostAPI` object in [src/BlockFrostAPI.ts](src/BlockFrostAPI.ts).
3. Add unit-test fixture for the added method to [test/fixtures/endpoints.ts](test/fixtures/endpoints.ts)
4. Regenerate wiki docs
- `yarn docs`
- push files to Wiki repository `https://github.com/blockfrost/blockfrost-js.wiki.git`
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"scripts": {
"build": "yarn clean && tsc",
"clean": "rimraf lib",
"docs": "yarn typedoc ./src/index.ts --theme github-wiki",
"lint": "eslint ./src/**/*.ts",
"prepublishOnly": "yarn build",
"test": "vitest",
Expand Down Expand Up @@ -51,9 +50,6 @@
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"serialize-error": "^11.0.2",
"typedoc": "^0.25.2",
"typedoc-github-wiki-theme": "^1.1.0",
"typedoc-plugin-markdown": "^3.16.0",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
},
Expand Down
146 changes: 0 additions & 146 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ __metadata:
prettier: "npm:^3.0.3"
rimraf: "npm:^5.0.5"
serialize-error: "npm:^11.0.2"
typedoc: "npm:^0.25.2"
typedoc-github-wiki-theme: "npm:^1.1.0"
typedoc-plugin-markdown: "npm:^3.16.0"
typescript: "npm:^5.2.2"
vitest: "npm:^0.34.6"
languageName: unknown
Expand Down Expand Up @@ -1018,13 +1015,6 @@ __metadata:
languageName: node
linkType: hard

"ansi-sequence-parser@npm:^1.1.0":
version: 1.1.0
resolution: "ansi-sequence-parser@npm:1.1.0"
checksum: b9a9bd4ce0ec58c90e1ca404f74b45b0dbbc96e8cb8d856ede122e2c5c2d3b6a1054f181dde22bc0f1f2a7ea971cdcb8f47c6fd76ed8878b3676416522df615a
languageName: node
linkType: hard

"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0":
version: 4.3.0
resolution: "ansi-styles@npm:4.3.0"
Expand Down Expand Up @@ -2442,24 +2432,6 @@ __metadata:
languageName: node
linkType: hard

"handlebars@npm:^4.7.7":
version: 4.7.7
resolution: "handlebars@npm:4.7.7"
dependencies:
minimist: "npm:^1.2.5"
neo-async: "npm:^2.6.0"
source-map: "npm:^0.6.1"
uglify-js: "npm:^3.1.4"
wordwrap: "npm:^1.0.0"
dependenciesMeta:
uglify-js:
optional: true
bin:
handlebars: bin/handlebars
checksum: 617b1e689b7577734abc74564bdb8cdaddf8fd48ce72afdb489f426e9c60a7d6ee2a2707c023720c4059070128243c948bded8f2716e4543378033e3971b85ea
languageName: node
linkType: hard

"has-flag@npm:^4.0.0":
version: 4.0.0
resolution: "has-flag@npm:4.0.0"
Expand Down Expand Up @@ -3125,13 +3097,6 @@ __metadata:
languageName: node
linkType: hard

"lunr@npm:^2.3.9":
version: 2.3.9
resolution: "lunr@npm:2.3.9"
checksum: f2f6db34c046f5a767782fe2454e6dd69c75ba3c5cf5c1cb9cacca2313a99c2ba78ff8fa67dac866fb7c4ffd5f22e06684793f5f15ba14bddb598b94513d54bf
languageName: node
linkType: hard

"magic-string@npm:^0.30.1":
version: 0.30.4
resolution: "magic-string@npm:0.30.4"
Expand Down Expand Up @@ -3194,15 +3159,6 @@ __metadata:
languageName: node
linkType: hard

"marked@npm:^4.3.0":
version: 4.3.0
resolution: "marked@npm:4.3.0"
bin:
marked: bin/marked.js
checksum: c830bb4cb3705b754ca342b656e8a582d7428706b2678c898b856f6030c134ce2d1e19136efa3e6a1841f7330efbd24963d6bdeddc57d2938e906250f99895d0
languageName: node
linkType: hard

"merge-stream@npm:^2.0.0":
version: 2.0.0
resolution: "merge-stream@npm:2.0.0"
Expand Down Expand Up @@ -3307,22 +3263,6 @@ __metadata:
languageName: node
linkType: hard

"minimatch@npm:^9.0.3":
version: 9.0.3
resolution: "minimatch@npm:9.0.3"
dependencies:
brace-expansion: "npm:^2.0.1"
checksum: c81b47d28153e77521877649f4bab48348d10938df9e8147a58111fe00ef89559a2938de9f6632910c4f7bf7bb5cd81191a546167e58d357f0cfb1e18cecc1c5
languageName: node
linkType: hard

"minimist@npm:^1.2.5":
version: 1.2.7
resolution: "minimist@npm:1.2.7"
checksum: 0202378a8eb1a9d98a44f623f43c89793a095f4bde6981bda29f6ae61e82a15c18b1690b5efc4c66ddbd402a3e9b7175e6ebdabb2b28037c279ac823b7360e00
languageName: node
linkType: hard

"minipass-collect@npm:^1.0.2":
version: 1.0.2
resolution: "minipass-collect@npm:1.0.2"
Expand Down Expand Up @@ -3532,13 +3472,6 @@ __metadata:
languageName: node
linkType: hard

"neo-async@npm:^2.6.0":
version: 2.6.2
resolution: "neo-async@npm:2.6.2"
checksum: 1a7948fea86f2b33ec766bc899c88796a51ba76a4afc9026764aedc6e7cde692a09067031e4a1bf6db4f978ccd99e7f5b6c03fe47ad9865c3d4f99050d67e002
languageName: node
linkType: hard

"nock@npm:^13.3.4":
version: 13.3.4
resolution: "nock@npm:13.3.4"
Expand Down Expand Up @@ -4299,18 +4232,6 @@ __metadata:
languageName: node
linkType: hard

"shiki@npm:^0.14.1":
version: 0.14.1
resolution: "shiki@npm:0.14.1"
dependencies:
ansi-sequence-parser: "npm:^1.1.0"
jsonc-parser: "npm:^3.2.0"
vscode-oniguruma: "npm:^1.7.0"
vscode-textmate: "npm:^8.0.0"
checksum: 6256651a5db0cfcb3069c483e8cc43765af24fce0df6e5fdb515e61d52b0880c06c43bc1e6f7ef1bd58bada38830e6e7367256ce9472e879af1c88c41231b13b
languageName: node
linkType: hard

"siginfo@npm:^2.0.0":
version: 2.0.0
resolution: "siginfo@npm:2.0.0"
Expand Down Expand Up @@ -4670,43 +4591,6 @@ __metadata:
languageName: node
linkType: hard

"typedoc-github-wiki-theme@npm:^1.1.0":
version: 1.1.0
resolution: "typedoc-github-wiki-theme@npm:1.1.0"
peerDependencies:
typedoc: ">=0.24.0"
typedoc-plugin-markdown: ">=3.15.0"
checksum: 84661e8c1a4540929b5a23bd8fcd81fdbdbf7f2d9338751bcb6861307fde08de7ddb876870e114aac34773590ced24de0b4c456fabc411bd9a41830ea069833f
languageName: node
linkType: hard

"typedoc-plugin-markdown@npm:^3.16.0":
version: 3.16.0
resolution: "typedoc-plugin-markdown@npm:3.16.0"
dependencies:
handlebars: "npm:^4.7.7"
peerDependencies:
typedoc: ">=0.24.0"
checksum: 1e9919ecf05630cdad6fde7a60915161fb3c95d07d266b0fb8a27fbc3e4536c362a328a9d8ec8cde53b28596aac88cf561d5b49f08514fbf9acf2bdb978fbe15
languageName: node
linkType: hard

"typedoc@npm:^0.25.2":
version: 0.25.2
resolution: "typedoc@npm:0.25.2"
dependencies:
lunr: "npm:^2.3.9"
marked: "npm:^4.3.0"
minimatch: "npm:^9.0.3"
shiki: "npm:^0.14.1"
peerDependencies:
typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x
bin:
typedoc: bin/typedoc
checksum: ba579427d09c4f3570382163e946820e041309d62c37cd061bf497b04b402ff0399a75836a4348ac11add882da0c4b563e7c196744955523cbdafc250149ad20
languageName: node
linkType: hard

"typescript@npm:^5.2.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
Expand Down Expand Up @@ -4741,15 +4625,6 @@ __metadata:
languageName: node
linkType: hard

"uglify-js@npm:^3.1.4":
version: 3.17.4
resolution: "uglify-js@npm:3.17.4"
bin:
uglifyjs: bin/uglifyjs
checksum: 4c0b800e0ff192079d2c3ce8414fd3b656a570028c7c79af5c29c53d5c532b68bbcae4ad47307f89c2ee124d11826fff7a136b59d5c5bb18422bcdf5568afe1e
languageName: node
linkType: hard

"unique-filename@npm:^2.0.0":
version: 2.0.1
resolution: "unique-filename@npm:2.0.1"
Expand Down Expand Up @@ -4931,20 +4806,6 @@ __metadata:
languageName: node
linkType: hard

"vscode-oniguruma@npm:^1.7.0":
version: 1.7.0
resolution: "vscode-oniguruma@npm:1.7.0"
checksum: 7da9d21459f9788544b258a5fd1b9752df6edd8b406a19eea0209c6bf76507d5717277016799301c4da0d536095f9ca8c06afd1ab8f4001189090c804ca4814e
languageName: node
linkType: hard

"vscode-textmate@npm:^8.0.0":
version: 8.0.0
resolution: "vscode-textmate@npm:8.0.0"
checksum: 9fa7d66d6042cb090d116c2d8820d34c8870cfcbaed6e404da89f66b899970ed0ac47b59a2e30fc40a25af5414822bb3ea27974f714e9b91910d69c894be95f7
languageName: node
linkType: hard

"wcwidth@npm:^1.0.1":
version: 1.0.1
resolution: "wcwidth@npm:1.0.1"
Expand Down Expand Up @@ -5030,13 +4891,6 @@ __metadata:
languageName: node
linkType: hard

"wordwrap@npm:^1.0.0":
version: 1.0.0
resolution: "wordwrap@npm:1.0.0"
checksum: 497d40beb2bdb08e6d38754faa17ce20b0bf1306327f80cb777927edb23f461ee1f6bc659b3c3c93f26b08e1cf4b46acc5bae8fda1f0be3b5ab9a1a0211034cd
languageName: node
linkType: hard

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0":
version: 7.0.0
resolution: "wrap-ansi@npm:7.0.0"
Expand Down
Loading