# User Profile

## **Get** Profile Details

<mark style="color:blue;">`GET`</mark> `‎‎https://<domain>/<api prefix>/<version>/user/get/profile/`

This API endpoint will give you the user profile details.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access-token |

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

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "UserProfile": [
            {
                "username": "<username>",
                "first_name": "<first name>",
                "last_name": "<last name>",
                "email": "<email>",
                "phone_code": "<phone code>",
                "phone_number": "<phone number>",
                "country_code": "<country code>"
            }
        ]
        "ProfileImage": "<image_path>",
        "UserLocInfo":{
            "lan": "<language_key>",
            "tz": "<timezone>",
            "currency": "<currency_code>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/profile/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/get/profile/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access-token>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

## **Update Profile Details**

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/user/update/profile/`

This API endpoint will update user profile details.

If the email address is changed, need to add token checksum field and token field for verification.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access-token |

#### Request Body

| Name                                    | Type   | Description                                                                                                                 |
| --------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| first\_name                             | string | first name                                                                                                                  |
| last\_name                              | string | last name                                                                                                                   |
| email<mark style="color:red;">\*</mark> | string | email address                                                                                                               |
| phone\_number                           | string | phone number                                                                                                                |
| languages                               | string | <p>language code</p><p><a data-mention href="#get-local-info">#get-local-info</a></p>                                       |
| currencies                              | string | <p>currency code</p><p><a data-mention href="#get-local-info">#get-local-info</a></p>                                       |
| timezones                               | string | <p>timezone</p><p><a data-mention href="#get-local-info">#get-local-info</a></p>                                            |
| token\_field                            | string | <p>Required when user update mail id,</p><p><a data-mention href="../payout#get-checksum-token">#get-checksum-token</a></p> |
| token\_checksum\_field                  | string | <p>Required when user update mail id,</p><p><a data-mention href="../payout#get-checksum-token">#get-checksum-token</a></p> |

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

```html
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/update/profile/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'first_name': '<first_name>',
    'last_name': '<last_name>',
    'email': '<email>',
    'phone_number': '<phone_number>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

#### **PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/update/profile/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('first_name' => '<first_name>','last_name' => '<last_name>','email' => '<email>','phone_number' => '<phone_number>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access-token>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field                  | Description                                                                       |
| ----------- | ---------------- | ---------------------- | --------------------------------------------------------------------------------- |
| 400         | Validation Error | email                  | <p>Enter a valid email address.</p><p>This field is required.</p>                 |
| 400         | Validation Error | phone\_number          | Phone number must be entered in the format: '999999999'. Up to 15 digits allowed. |
| 400         | Validation Error | first\_name            | Ensure this field has no more than 255 characters.                                |
| 400         | Validation Error | last\_name             | Ensure this field has no more than 255 characters.                                |
| 400         | Validation Error | token\_checksum\_field | This field is required.                                                           |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>Token is not matching.</p>                       |

## Upload profile image

<mark style="color:green;">`POST`</mark> `‎‎‎‎https://<domain>/<api prefix>/<version>/user/profile-image/`

This API endpoint is for uploading a user profile image

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access-token |

#### Request Body

| Name                                             | Type   | Description           |
| ------------------------------------------------ | ------ | --------------------- |
| image<mark style="color:red;">\*</mark>          | object | image file(Type file) |
| cropped\_image<mark style="color:red;">\*</mark> | object | image file(Type file) |

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

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "image_url": "<image_url>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/profile/profile-image/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'image': {
      'value': <image uri>,
      'options': {
        'filename': '<image name>',
        'contentType': null
      },
    'cropped_image': {
      'value': <cropped_image uri>,
      'options': {
        'filename': '<cropped_image name>',
        'contentType': null
    }
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/profile/profile-image/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('<image root path>'), 'cropped_image'=> new CURLFILE('<cropped_image root path>')),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access-token>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field          | Description                                                                                             |
| ----------- | ---------------- | -------------- | ------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | image          | Upload a valid image. The file you uploaded was either not an image or a corrupted image.               |
| 400         | Validation Error | cropped\_image | Upload a valid image. The file you uploaded was either not an image or a corrupted image.               |
| 429         | Throttled        |                | Your daily profile update limit exceeded. Expected available in \<HH> hours \<M minutes and ss seconds. |

## Get Local Info

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/get/local-info/`

This API endpoint will return list site-local info such as currency list, language list, and timezones list.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200: OK " %}

```html
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status_code": 200,
    "errors": {},
    "data": {
        "languages": [
            {
                "key": "<language_key>",
                "name": "<language_name>"
            },
            ...
        ],
        "currencies": [
            {
                "key": "<currency_code>",
                "name": "<currency_name>"
            },
            ...
        ],
        "timezones": [
            {
                "key": "<timezone_key>",
                "name": "<timezone_name>"
            },
        ]
    }
}
        
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/local-info/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/get/local-info/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```
