🖊️Calling APIs on Blockflow

Once you have created an API on Blockflow, you can invoke it using the following endpoint formats:

  1. Using API ID:

    https://api.blockflow.network/api/<apiId>
  2. Using API Slug and Project ID:

https://api.blockflow.network/api/<apiSlug>?projectId=<projectId>

API ID and Project ID

You can find the apiId and projectId on your Blockflow dashboard. These identifiers are unique to each API and project, respectively.

  • apiId: The unique identifier assigned to your API.

  • projectId: The unique identifier assigned to your project.

API Slug

The apiSlug is a user-defined, URL-friendly name for your API. You specify the API slug during the API creation process. It allows you to use a more descriptive and meaningful name in the API endpoint URL.

Examples

Let's say you have an API with the following details:

  • API ID: "123"

  • Project ID: "456"

  • API Slug: "test"

You can call the API using either of the following endpoints:

  1. Using API ID:

    https://api.blockflow.network/api/123
  2. Using API Slug and Project ID:

    https://api.blockflow.network/api/test?projectId=456

Authentication

When calling your API, make sure to include the necessary authentication credentials as specified in your API configuration. This will include API keys, tokens, or other authentication mechanisms.

Query Parameters and Request Body

Depending on your API design, you may need to pass additional query parameters or include a request body when making API calls. Refer to this guide to understand the required parameters and request format.

Error Handling

If an error occurs while calling your API, Blockflow will return an appropriate HTTP status code along with an error message in the response body.

API Documentation

To provide a better developer experience, it's recommended to document your API endpoints, request/response formats, and any authentication requirements. You can use tools like Swagger or Postman to create and host your API documentation.

Example API Call

Here's an example of making an API call to your Blockflow API using JavaScript and the Fetch API:

fetch('https://api.blockflow.network/api/123', {
  method: 'GET',
  headers: {
    'x-api-key': '<your-api-key>',
    'Content-Type': 'application/json'
  }
})
  .then(response => response.json())
  .then(data => {
    // Handle the API response data
    console.log(data);
  })
  .catch(error => {
    // Handle any errors that occurred during the API call
    console.error('Error:', error);
  });