Business Categories

Overview

A business category is a set of data sources for a type of business.

Example: {"name": "Restaurant", "sources": [1,2,3,4,5,7,18,20]}

In the example above, Restaurant is associated to Google, Yelp, Yellow Pages, Zomato, Foursquare, Facebook, Tripadvisor, and Open Table.

Default Fields

The following fields are used to access business data:

FieldTypeDescription
name
stringThe name associated to the Business object. This can be the same name as an account.
sourcesarrayAn array of the data source ids associated with the category name.

List All Business Categories

Use this URL to request all business categories for the authenticated user:

https://ad1.replypro.io/api/public/categories

https://ad1.replypro.io/api/public/account/<account_id>/categories

Example of returned data:

{
    "results": [
        {
            "sources": [
                1,
                2,
                3,
                5,
                7,
                13,
                14,
                15,
                16,
                17,
                18,
                22,
                23
            ],
            "name": "Hotel"
        },
        {
            "sources": [
                1,
                2,
                3,
                4,
                5,
                7,
                18,
                20
            ],
            "name": "Restaurant"
        },
        {
            "sources": [
                1,
                2,
                4,
                5,
                7,
                18
            ],
            "name": "test"
        },
        {
            "sources": [
                1,
                2,
                3,
                4
            ],
            "name": "testing"
        }
    ]
}

Get Business Category

Use this URL to request a single business category object for a given business:

https://ad1.replypro.io/api/public/categories/<business_id>

https://ad1.replypro.io/api/public/accounts/<account_id>/companies/<company_id>/businesses/<business_id>/categories

Example of Returned Data:

{
    "results": [
        {
            "sources": [
                1,
                2,
                3,
                4,
                5,
                7,
                18,
                20
            ],
            "name": "Restaurant"
        }
    ]
}

Alternatively, a payload may be used to request a single business category object for a given business:

payload = {
  "business_id": business_id,
  "account_id": account_id,
}
get("https://ad1.replypro.io/api/public/categories/", data=payload, format="json)

Filter Business Category by name

This is an example of requesting business categories by name:

https://ad1.replypro.io/api/public/categories?name=test

Example of returned data with filter:

{
    "results": [
        {
            "sources": [
                1,
                2,
                4,
                5,
                7,
                18
            ],
            "name": "test"
        },
        {
            "sources": [
                1,
                2,
                3,
                4
            ],
            "name": "testing"
        }
    ]
}

A payload may also be used:

payload = {
  "business_id": business_id,
  "account_id": account_id,
  "name": test
}
get("https://ad1.replypro.io/api/public/categories/", data=payload, format="json)

Adding Business Categories

To create a new Business Category, submit a POST request to following URL containing, at minimum, the name, business_id, and sources for the new Business Category. This information may also be contained in a payload.

This endpoint can also be used to add an existing Business Category to a business using the name of the category and the id of the business without including sources in the request.

🚧

Sources are not necessary for existing Business Categories

If you are attempting to add an existing Business Category to a business with the sources parameter set this endpoint will return a data conflict error to avoid overwriting the category with a new set of sources. If you wish to change a Business Category for all businesses the PUT method should be used instead.

Using a URL:

https://ad1.replypro.io/api/public/categories/<business_id>?name=test&sources[]=1&sources[]=2&sources[]=3&sources[]=4
{
  "name": "Added Business",
  "address": "123 Test Ave",
  "locality": "Boise",
  "province": "Idaho",
  "remote_id": 124579, // Optional field
  "group_id": 21 // Optional field, must be an already existing Group
}

Using a payload:

payload = {
  "business_id": business_id,
  "name": 'test',
  "sources": [1, 2, 3, 4]
}
post("https://ad1.replypro.io/api/public/categories", data=payload, format="json")

The return from a successful POST to create a business would look something like the following:

{
    "results": [
        {
            "sources": [
                1,
                2,
                3,
                4
            ],
            "name": "test"
        }
    ]
}

Updating the Business Category

You can update sources on a Business Category by making a PUT request to the endpoint with the sources you are updating specified in the body.

🚧

Overwrites existing category

Doing a PUT on the category will change the business category for all businesses attached to the category you are changing.

https://ad1.replypro.io/api/public/categories

In the sample below, we will be making a request to update the sources of a business category using the url https://ad1.replypro.io/api/public/categories.

{
  "name": "test",
  "sources": [11,12,13]
}

The response to the above request would be as follows:

{
    "results": [
        {
            "sources": [
                11,
                12,
                13
            ],
            "name": "test"
        }
    ]
}