|
19 | 19 | <a href="https://discord.gg/ES2rDhBJt3">
|
20 | 20 | <img src="https://img.shields.io/badge/-Discord-414EEC?style=flat-square&logo=discord&logoColor=white" />
|
21 | 21 | </a>
|
| 22 | + <a href="https://www.npmjs.com/package/@maestro-org/typescript-sdk"> |
| 23 | + <img src="https://img.shields.io/npm/dm/typescript-sdk?style=flat-square&logo=npm&labelColor=black&color=pink&link=https%3A%2F%2F" /> |
| 24 | + </a> |
22 | 25 | </p>
|
23 | 26 | </p>
|
24 | 27 |
|
25 | 28 | # Getting Started
|
26 | 29 |
|
| 30 | +## Installation |
| 31 | + |
| 32 | +### [NPM](https://www.npmjs.com/package/@maestro-org/typescript-sdk) |
| 33 | +```bash |
| 34 | +npm i @maestro-org/typescript-sdk |
| 35 | +``` |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```ts |
| 40 | +import { MaestroClient, Configuration } from "@maestro-org/typescript-sdk"; |
| 41 | + |
| 42 | +let maestroClient = new MaestroClient( |
| 43 | + new Configuration({ |
| 44 | + apiKey: "<PROJECT_API_KEY>", |
| 45 | + network: "Preprod", |
| 46 | + }) |
| 47 | +); |
| 48 | +``` |
| 49 | +* To generate an API key, create a free account [here](https://dashboard.gomaestro.org/)! |
| 50 | +* Network options: `Preview`, `Preprod`, `Mainnet`, `Sanchonet` |
| 51 | + |
| 52 | +## Example |
| 53 | + |
| 54 | +```ts |
| 55 | +import { MaestroClient, Configuration } from "@maestro-org/typescript-sdk"; |
| 56 | + |
| 57 | +let maestroClient = new MaestroClient( |
| 58 | + new Configuration({ |
| 59 | + apiKey: "<PROJECT_API_KEY>", |
| 60 | + network: "Preprod", |
| 61 | + }) |
| 62 | +); |
| 63 | + |
| 64 | +maestroClient.addresses |
| 65 | + .utxosByAddress( |
| 66 | + "aasdddr_test1qqe9k9zmswzx9h9vaaf49shun82t8nr52h0ptpgumzxjjqm6wlgjpw0gdtwuwwydhwcm6g6sfy9h69q2kg6q8p3jxdxsrrxrdm" |
| 67 | + ) |
| 68 | + .then((x) => console.log(x.data)) |
| 69 | + .catch((error) => { |
| 70 | + if (error.response) { |
| 71 | + // The request was made and the server responded with a status code |
| 72 | + // that falls out of the range of 2xx |
| 73 | + console.log(error.response.data); |
| 74 | + console.log(error.response.status); |
| 75 | + console.log(error.response.headers); |
| 76 | + } else if (error.request) { |
| 77 | + // The request was made but no response was received |
| 78 | + // `error.request` is an instance of XMLHttpRequest in the browser and an instance of |
| 79 | + // http.ClientRequest in node.js |
| 80 | + console.log(error.request); |
| 81 | + } else { |
| 82 | + // Something happened in setting up the request that triggered an Error |
| 83 | + console.log("Error", error.message); |
| 84 | + } |
| 85 | + }); |
| 86 | +maestroClient.addresses |
| 87 | + .utxosByAddresses([ |
| 88 | + "addr_test1qqe9k9zmswzx9h9vaaf49shun82t8nr52h0ptpgumzxjjqm6wlgjpw0gdtwuwwydhwcm6g6sfy9h69q2kg6q8p3jxdxsrrxrdm", |
| 89 | + ]) |
| 90 | + .then((x) => console.log(x.data)); |
| 91 | + |
| 92 | +``` |
| 93 | + |
27 | 94 | # Documentation
|
28 | 95 |
|
29 | 96 | * [Maestro public docs](https://docs.gomaestro.org/)
|
|
0 commit comments