API Service
Connecting you to the world of web3 through API's
Dashboard
The dashboard gives access to all the available features on Blockops and provides a side navigation for easy navigation.
To get started, visit blockops.network and navigate to the API Service page on the dashboard. This allows you to connect to a network which generates your API keys.
Supported Networks
Blockops' API Service supports:
Gnosis
Cronos
Polygon and
Base, all easily accessable from the dashboard.
Search
The search bar provides you easy access to accessing your API endpoints
Initial Setup
Click Create New
to connect to any of the available networks on Blockops. Select the network you want to connect, and enter your project’s name.
The API Endpoint List shows all active and deploying projects, the network type, the creation date, and the status of the project.
Once you are connected to a network, an API key will automatically be generated for you. Click on that project to view the network endpoint and the API key – a token required for the interaction with the service and making API requests.
Practical Examples
Connect via a command line
You can connect to the network using websocket or HTTP with your API key in two ways:
Adding the API key as a query string
?api_key=${APIKEY}
Or the request header
H 'authorization: APIKEY ${APIKEY}'
Curl
For example, the following CURL command can be used to get header and body of a relay chain block.
curl -H "Content-Type: application/json" -H 'authorization: APIKEY xxxx' -d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock"}' <https://polkadot-rpc.blockops.network/rpc
>
Here is the response you will receive back:
{"jsonrpc":"2.0","result":{"block":{"header":{"parentHash":"0x381dd358f0b1e328e861822b2a51a72e8dc064803a5c7ccc96277da3b16d7667","number":"0xe07a1d","stateRoot":"0xa2aacd7ef5d7ff66da1df6643b3e1c13975d210363c568f1bed51bad56cf40db","extrinsicsRoot":"0x00bc7f1504c9a07364835d80d2114ca3d4e7ad774453198b119bea9be2a1f7c1","digest":{"logs":["0x0642414245b50103d8000000d17aae1000000000768dc1931ba697bb9ab4a08debf5d710bd1f55e6325d65315161c2340cc0217170dfe2df24a3680c8ff48868ac665f4b34ebefa4bc844d510c848d9fc99252035db579a0acbf52cded336d6daf6ab7fdb1d1eee0d480e6388c2a12785d4de809"]},"justifications":null},"id":1}
Wscat
If you want to send data requests with WebSockets, you can use several libraries or wscat. You can install and use wscat as follows:
Download wscat from https://www.npmjs.com/package/wscat
Install wscat by running the following command:
npm install -g wscat
You can connect to the network with wscat using two options by adding the API key as a query string.
wscat -c 'wss://polkadot-rpc.blockops.network/ws' --header 'authorization: APIKEY xxxx’
Or the request header.
wscat -c 'wss://polkadot-rpc.blockops.network/ws?api_key=**********************’
After executing the command, the terminal will display a message indicating that the connection has been enabled successfully.
Connected (press CTRL+C to quit)
Then, you can send the following request:
{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock"}
Connect via Polkadot JS UI
Maintain existing example from API Service | Blockops
Rotate API Key
Rotating API keys is important when an unauthorised third party have access to your API key. You have the option to reset it by using the Rotate Key button located in the project dashboard
API Service Rate Limiting
Maintain existing example from API Service | Blockops
API Error Codes
The following error codes are frequently returned by our API service. However, it's important to note that this list doesn't include errors related to network-specific business logic.
Card | Message | Explanation |
---|---|---|
401 | Unauthorized Access | Invalid API key or no API key found in request |
404 | No route matched | This indicates the specific page you are trying to visit is non-existent |
500 | Internal Server Error | Something went wrong inside our servers. Contact support. |
429 | Too Many Requests | You have exceeded your request limit. |
Conclusion
Blockops API service is a gateway to accessing your endpoint with ease and securely
Follow us on Twitter for more information on upcoming protocols and developments.
Last updated