---
title: Nearest branch fetch
slug: api-marketplace/nearest-branch-fetch
createdAt: 2025-01-17T08:12:32.762Z
---

This API enables banks to find the nearest branch based on a customer’s geocode (latitude and longitude). Using advanced geospatial algorithms, the API calculates and returns the closest branch location in real-time, optimizing lead allocation.
**Key Features:**
Input: Customer geocode (latitude and longitude).
Output: Nearest branch information, including branch ID, name, address, and distance from the customer.
&#x20;1\. High-speed response to support real-time decision-making.
&#x20;2\. These APIs are designed to provide a seamless and efficient lead allocation solution,       helping banks improve their operational efficiency and customer satisfaction.

## API details

### Endpoint

:::CodeblockTabs
Production Endpoint

```text
POST https://api.signzy.app/api/v3/nearest-branch/fetch
```
:::

:::CodeblockTabs
UAT Endpoint

```text
POST https://api-preproduction.signzy.app/api/v3/nearest-branch/fetch
```
:::

***

### Request body parameters

| **Parameter** | **Data Type** | **Description**                                               | **Required** |
| ------------- | ------------- | ------------------------------------------------------------- | ------------ |
| fileId        | Object        | File ID for previous flow                                     | Mandatory    |
| latitude      | String        | Latitude of the point from where you want to fetch distance   | Optional     |
| longitude     | String        | Longitude of that point from where you want to fetch distance | Optional     |
| address       | String        | Address of that point from where you want to fetch distance   | Optional     |

### Request body&#x20;

```json
{
    "fileId": "a2521a3c7b6942ed9065a8f81b9ceceb",
    "latitude": "37.7748",
    "longitude": "-122.4194"
    "address": ""
}   
```

***

### Request Headers

| **Name&#x20;** | **Value**        | **Required** | **Description**                                                                                            |
| -------------- | ---------------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
| Content-type   | application/json | Mandatory    | The type of content that the request body contains.                                                        |
| Authorization  | XXXXXXXXXXXXXXX  | Mandatory    | An authentication token to authorize the request. Reach out to the Signzy support team to get one created. |

***

### Code Samples

:::CodeblockTabs
Curl

```json
curl --location 'https://api-preproduction.signzy.app/api/v3/nearest-branch/fetch' \
--header 'Content-Type: application/json' \
--header 'Authorization: <auth token>' \
--data '{
    "fileId": "a2521a3c7b6942ed9065a8f81b9ceceb",
    "latitude": "37.7748",
    "longitude": "-122.4194",
    "address": ""
}   '
```

Node.js

```nodejs
const axios = require('axios');
let data = JSON.stringify({
  "fileId": "a2521a3c7b6942ed9065a8f81b9ceceb",
  "latitude": "37.7748",
  "longitude": "-122.4194",
  "address": ""
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-preproduction.signzy.app/api/v3/nearest-branch/fetch',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': '<auth token>'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

Python

```python
import requests
import json

url = "https://api-preproduction.signzy.app/api/v3/nearest-branch/fetch"

payload = json.dumps({
  "fileId": "a2521a3c7b6942ed9065a8f81b9ceceb",
  "latitude": "37.7748",
  "longitude": "-122.4194",
  "address": ""
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': '<auth token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

GO

```go
package main

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

func main() {

  url := "https://api-preproduction.signzy.app/api/v3/nearest-branch/fetch"
  method := "POST"

  payload := strings.NewReader(`{
    "fileId": "a2521a3c7b6942ed9065a8f81b9ceceb",
    "latitude": "37.7748",
    "longitude": "-122.4194",
    "address": ""
}   `)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "<auth token>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```
:::

***

### Response body parameters

| **Parameter**             | **Data Type** | **Description**                                          |
| ------------------------- | ------------- | -------------------------------------------------------- |
| result                    | Object        | The root object containing the result of the operation.  |
| result.originAddress      | String        | The address representing the origin of the journey.      |
| result.destinationAddress | String        | The address representing the destination of the journey. |
| result.mode               | String        | The mode of transportation used for the journey.         |
| result.distanceInMeters   | Integer       | The distance of the journey in meters.                   |
| result.durationInSeconds  | Integer       | The duration of the journey in seconds.                  |

:::CodeblockTabs
200

```json
{
    "result": {
        "nearestPoint": {
            "latitude": 37.7749,
            "longitude": -122.4194
        },
        "distanceInMeter": 440,
        "coordinates": {
            "latitude": 37.7748,
            "longitude": -122.4194
        }
    }
}
```

400

```json
{
    "error": {
        "name": "error",
        "message": "fileId is not allowed to be empty",
        "status": 400,
        "reason": "VALIDATION_ERROR",
        "type": "Bad Request",
        "statusCode": 400
    }
}
```

401

```json
// If Authorization token is not passed
{
    "message": "No API key found in request"
}

// If Authorization token is invalid
{
    "message": "Invalid authentication credentials"
}
```

404

```json

{
    "error": {
        "statusCode": 404,
        "name": "Error",
        "message": "No Result found",
        "status": 404
    }
}
```

409

```json
{
    "error": {
        "name": "error",
        "message": "Upstream Down",
        "status": 409,
        "statusCode": 409
    }
}
```
:::

**Contact Us for Any Assistance**

If you have any questions or need assistance, please reach out to our customer support team. You can contact us via email at <font color="#2166ae">**help\@signzy.com**</font>. We strive to provide prompt and reliable assistance, ensuring your queries are addressed effectively.

We value your feedback and are committed to making your experience smooth and enjoyable. Our team is dedicated to assisting you with any needs you may have. Thank you for choosing our services. We look forward to helping you!
