# Hair Changer API

### About

This API empowers users to effortlessly explore various hairstyles, experiment with hair colors, and virtually try out different haircuts, all through simple API endpoints.

With the Hair Changer API, developers can enable users to upload their images and apply desired changes to their hairstyles or hair colors in real-time. By leveraging this API, developers can enhance user experiences by providing them with personalized and interactive features related to hair styling.

This API supports essential functionalities such as changing hairstyles, modifying hair colors, and trying virtual haircuts. Developers can integrate these features into a wide range of applications, including virtual makeover apps, beauty salon booking platforms, or fashion styling tools.

Users can access the Hair Changer API securely through authentication using API keys, ensuring data privacy and security. Additionally, the API incorporates rate limits to manage usage and prevent abuse, promoting fair and efficient utilization.

For developers seeking to enhance their applications with hair modification capabilities, the Hair Changer API offers comprehensive documentation, error handling support, and dedicated customer assistance. Get started today and bring dynamic hair styling functionalities to your applications with ease.

#### Developer Portal: <https://api.market/store/magicapi/hair>

![image](https://telegra.ph/file/62fd9ab2924175f8fa14e.png)

<figure><img src="/files/INjqrDlSGOHdzmYnwUNe" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/RBp65l9FPGNw4xnJCvYS" alt=""><figcaption></figcaption></figure>

### Curl Requests and Responses <a href="#curl-requests-and-responses" id="curl-requests-and-responses"></a>

**Process the image**

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'POST' \
  'https://api.magicapi.dev/api/v1/magicapi/hair/hair' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "image": "https://replicate.delivery/mgxm/b8be17a7-abcb-4421-80f2-e6a1e3fe38c7/MarkZuckerberg.jpg",
  "editing_type": "both",
  "color_description": "blond",
  "hairstyle_description": "hi-top fade hairstyle"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY',
    'Content-Type': 'application/json',
}

json_data = {
    'image': 'https://replicate.delivery/mgxm/b8be17a7-abcb-4421-80f2-e6a1e3fe38c7/MarkZuckerberg.jpg',
    'editing_type': 'both',
    'color_description': 'blond',
    'hairstyle_description': 'hi-top fade hairstyle',
}

response = requests.post('https://api.magicapi.dev/api/v1/magicapi/hair/hair', headers=headers, json=json_data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.magicapi.dev/api/v1/magicapi/hair/hair');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-magicapi-key: API_KEY',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n  \"image\": \"https://replicate.delivery/mgxm/b8be17a7-abcb-4421-80f2-e6a1e3fe38c7/MarkZuckerberg.jpg\",\n  \"editing_type\": \"both\",\n  \"color_description\": \"blond\",\n  \"hairstyle_description\": \"hi-top fade hairstyle\"\n}");

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://api.magicapi.dev/api/v1/magicapi/hair/hair',
  {
    'image': 'https://replicate.delivery/mgxm/b8be17a7-abcb-4421-80f2-e6a1e3fe38c7/MarkZuckerberg.jpg',
    'editing_type': 'both',
    'color_description': 'blond',
    'hairstyle_description': 'hi-top fade hairstyle'
  },
  {
    headers: {
      'accept': 'application/json',
      'x-magicapi-key': 'API_KEY',
      'Content-Type': 'application/json'
    }
  }
);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://api.magicapi.dev/api/v1/magicapi/hair/hair', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    'image': 'https://replicate.delivery/mgxm/b8be17a7-abcb-4421-80f2-e6a1e3fe38c7/MarkZuckerberg.jpg',
    'editing_type': 'both',
    'color_description': 'blond',
    'hairstyle_description': 'hi-top fade hairstyle'
  })
});
```

{% endtab %}
{% endtabs %}

```json
{
  "request_id": REQUEST_ID
}
```

**Get the result**

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'GET' \
  'https://api.magicapi.dev/api/v1/magicapi/hair/predictions/REQUEST_ID' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: API_KEY'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
}

response = requests.get('https://api.magicapi.dev/api/v1/magicapi/hair/predictions/REQUEST_ID', headers=headers)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.magicapi.dev/api/v1/magicapi/hair/predictions/REQUEST_ID');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-api-market-key: API_KEY',
]);

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.get('https://api.magicapi.dev/api/v1/magicapi/hair/predictions/REQUEST_ID', {
  headers: {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY'
  }
});
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://api.magicapi.dev/api/v1/magicapi/hair/predictions/REQUEST_ID', {
  headers: {
    'accept': 'application/json',
    'x-api-market-key  }
});
```

{% endtab %}
{% endtabs %}

```json
{
  "status": "succeeded",
  "result": "RESULT_URL"
}
```

### Parameters

`color_description` would be -  purple, red, orange, yellow, green, blue, gray, brown, black, white, blond, pink

`hairstyle_description` would be these:

```
afro hairstyle
bob cut hairstyle
bowl cut hairstyle
braid hairstyle
caesar cut hairstyle
chignon hairstyle
cornrows hairstyle
crew cut hairstyle
crown braid hairstyle
curtained hair hairstyle
dido flip hairstyle
dreadlocks hairstyle
extensions hairstyle
fade hairstyle
fauxhawk hairstyle
finger waves hairstyle
french braid hairstyle
frosted tips hairstyle
full crown hairstyle
harvard clip hairstyle
high and tight hairstyle
hime cut hairstyle
hi-top fade hairstyle
jewfro hairstyle
jheri curl hairstyle
liberty spikes hairstyle
marcel waves hairstyle
mohawk hairstyle
pageboy hairstyle
perm hairstyle
pixie cut hairstyle
psychobilly wedge hairstyle
quiff hairstyle
regular taper cut hairstyle
ringlets hairstyle
shingle bob hairstyle
short hair hairstyle
slicked-back hairstyle
spiky hair hairstyle
surfer hair hairstyle
taper cut hairstyle
the rachel hairstyle
undercut hairstyle
updo hairstyle
```


---

# 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.api.market/api-product-docs/magicapi/hair-changer-api.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.
