# 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.

{% content-ref url="/pages/8aJD9jlQNgass2XMdlXM" %}
[How to write API logics](/guides/creating-an-api/how-to-write-api-logics.md)
{% endcontent-ref %}

### **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.&#x20;

### **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:

```javascript
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);
  });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blockflow.network/guides/creating-an-api/calling-apis-on-blockflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
