# For Developers

{% hint style="info" %}
**Good to know:** [The DeStor REST API for Filecoin specs](https://github.com/filecoin-project/motion/blob/main/openapi.yaml)
{% endhint %}

## POST data

Here are some PUT data examples of how to use Python, cURL, and Golang to interact with the provided API endpoints:

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl -X POST 'http://localhost:50000/v0/blob' \
  --data-binary @your_data_file \
  -H 'Content-Type: application/octet-stream'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" fullWidth="true" %}

```python
import requests

url = 'http://localhost:50000/v0/blob'
data = b'Your binary data here'

response = requests.post(url, data=data, headers={'Content-Type': 'application/octet-stream'})

if response.status_code == 201:
    print("Data successfully created. Blob ID:", response.json()['id'])
else:
    print("Error:", response.status_code)
```

{% endcode %}
{% endtab %}

{% tab title="Golang" %}
{% code overflow="wrap" %}

```go
package main

import (
	"bytes"
	"fmt"
	"net/http"
)

func main() {
	url := "http://localhost:50000/v0/blob"
	data := []byte("Your binary data here")

	resp, err := http.Post(url, "application/octet-stream", bytes.NewReader(data))
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	if resp.StatusCode == 201 {
		fmt.Println("Data successfully created. Blob ID:", resp.Header.Get("id"))
	} else {
		fmt.Println("Error:", resp.Status)
	}
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Please note that you'll need to replace `'unique-blob-id'` and `'your_data_file'` with actual values or data when making requests with cURL or the provided code samples.

## GET data

Here are some GET data examples of how to use Python, cURL, and Golang to interact with the provided API endpoints:

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl -o downloaded_data.bin 'http://localhost:50000/v0/blob/unique-blob-id'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" fullWidth="true" %}

```python
import requests

blob_id = 'unique-blob-id'
url = f'http://localhost:50000/v0/blob/{blob_id}'

response = requests.get(url)

if response.status_code == 200:
    # Handle the binary data in response.content
    with open('downloaded_data.bin', 'wb') as file:
        file.write(response.content)
else:
    print("Error:", response.status_code)
```

{% endcode %}
{% endtab %}

{% tab title="Golang" %}
{% code overflow="wrap" %}

```go
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	blobID := "unique-blob-id"
	url := fmt.Sprintf("http://localhost:50000/v0/blob/%s", blobID)

	resp, err := http.Get(url)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	if resp.StatusCode == 200 {
		data, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			fmt.Println("Error:", err)
			return
		}

		err = ioutil.WriteFile("downloaded_data.bin", data, 0644)
		if err != nil {
			fmt.Println("Error:", err)
			return
		}
	} else {
		fmt.Println("Error:", resp.Status)
	}
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Please note that you'll need to replace `'unique-blob-id'` and `'your_data_file'` with actual values or data when making requests with cURL or the provided code samples.

## STATUS

Here are some STATUS examples of how to use Python, cURL, and Golang to interact with the provided API endpoints:

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl 'http://localhost:50000/v0/blob/unique-blob-id/status'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" fullWidth="true" %}

```python
import requests

url = 'http://localhost:50000/v0/blob'
data = b'Your binary data here'

response = requests.post(url, data=data, headers={'Content-Type': 'application/octet-stream'})

if response.status_code == 201:
    print("Data successfully created. Blob ID:", response.json()['id'])
else:
    print("Error:", response.status_code)
```

{% endcode %}
{% endtab %}

{% tab title="Golang" %}
{% code overflow="wrap" %}

```go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	blobID := "unique-blob-id"
	url := fmt.Sprintf("http://localhost:50000/v0/blob/%s/status", blobID)

	resp, err := http.Get(url)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	if resp.StatusCode == 200 {
		var statusData map[string]interface{}
		err := json.NewDecoder(resp.Body).Decode(&statusData)
		if err != nil {
			fmt.Println("Error:", err)
			return
		}

		fmt.Println("Blob ID:", statusData["id"])
		replicas := statusData["replicas"].([]interface{})
		for _, replica := range replicas {
			replicaData := replica.(map[string]interface{})
			fmt.Println("Provider:", replicaData["provider"])
			fmt.Println("Status:", replicaData["status"])
			fmt.Println("Last Verified:", replicaData["lastVerified"])
			fmt.Println("Expiration:", replicaData["expiration"])
		}
	} else {
		fmt.Println("Error:", resp.Status)
	}
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Please note that you'll need to replace `'unique-blob-id'` and `'your_data_file'` with actual values or data when making requests with cURL or the provided code samples.


---

# 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.destor.io/destor-rest-api-for-filecoin/for-developers.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.
