# Search

The main endpoint for retrieving businesses is `/companies/`. When called without any parameters, this will return all available businesses in the database.

In order to perform searches, various filters are added to the companies. These can all be combined together; for example, to retrieve all manufacturing (SIC section D) companies near the centre of Oldham the query would be:

```
https://api2.redflagalert.net/v4/companies/?sic_section=D&postcode=OL11HD&distance=3miles
```

#### Results per page

By default a single search response page contains 50 results. This can be overridden by sending the `results_per_page` parameter as a valid integer:

```
https://api2.redflagalert.net/v4/companies/?postcode=OL11HD&results_per_page=100
```

#### Search Parameters

Various search filters are available and we expect these to be steadily added to as the API develops. If you require a search which is not currently available, please [contact us](mailto:helpdesk@redflagalert.com) to suggest it.

| Search Parameter                                                                                               | Description                                                                                                                | Examples                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Notes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `postcode`                                                                                                     | Search within a specified radius of a UK postcode.                                                                         | <p><code><https://api2.redflagalert.net/v4/companies/?postcode=SW1A%202AA></code></p><p>Returns businesses with postcode SW1A 2AA</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Where we have multiple addresses for a business, if any of them match the postcode filter then the business will be included in the search results.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `distance`                                                                                                     | Search within a specified radius of a UK postcode.                                                                         | <p><code><https://api2.redflagalert.net/v4/companies/?postcode=SW1A%202AA&#x26;distance=3miles></code></p><p>Returns businesses within a 3 mile radius of SW1A 2AA</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Where we have multiple addresses for a business, if any of them match the postcode filter then the business will be included in the search results.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <p><code>has\_contact</code></p><p><code>has\_phone\_contact</code></p><p><code>has\_email\_contact</code></p> | Filter companies based on available contact information.                                                                   | <p><code><https://api2.redflagalert.net/v4/companies/?has_contact=true></code></p><p>Returns companies which have a contact phone number or a contact email address.</p><p><code><https://api2.redflagalert.net/v4/companies/?has_email_contact=true></code></p><p>Returns companies which have a contact email address.</p><p><code><https://api2.redflagalert.net/v4/companies/?has_email_contact=false&#x26;has_phone_contact=true></code></p><p>Returns companies with no contact email address but with a contact phone number.</p>                                                                                                                                                                                                                                                             | All of these filters take a boolean value; e.g. 'true' or 'false'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `exclude_non_trading`                                                                                          | Filter out non-trading companies (rated 'Discontinued', 'Dissolved', 'Not-trading' or 'Strike Off').                       | `https://api2.redflagalert.net/v4/companies/?exclude_non_trading=true`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | The filter does not return only non trading companies if set to 'false'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `has_filed_accounts`                                                                                           | Filter companies with accounting data i.e. who have filed accounts.                                                        | `https://api2.redflagalert.net/v4/companies/?has_filed_accounts=true`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Returns companies which have at least one set of figures for balance sheet, profit and loss, cashflow, or ratio analysis. Setting it to false will only return companies who have none of these data.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `is_limited`                                                                                                   | Filter search results to include/exclude registered/limited companies.                                                     | <p><code><https://api2.redflagalert.net/v4/companies/?is_limited=true></code></p><p>Only returns companies which are registered/limited.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | This filter takes a boolean value; e.g. 'true' or 'false'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `match_name`                                                                                                   | A simple closest text match on the name of the business.                                                                   | <p><code><https://api2.redflagalert.net/v4/companies/?match_name=red%20flag%20a!ert%20llp></code></p><p>Will return Red Flag A!ert first, followed by other similar matches.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `auditor`                                                                                                      | Query on the name of the business's auditor                                                                                | `https://api2.redflagalert.net/v4/companies/?auditor=begbies`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `auditor_match_name_prefix`                                                                                    | Match text at the beginning of the business's auditor                                                                      | `https://api2.redflagalert.net/v4/companies/?auditor_match_name_prefix=begbies`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `match_name_prefix`                                                                                            | Also a text match, but focuses on the beginning of the company name.                                                       | <p><code><https://api2.redflagalert.net/v4/companies/?match_name_prefix=red> flag</code></p><p>Returns all businesses whose name starts with ‘red flag’.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Most commonly used for autocomplete-style search                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>min\_birthdate</code></p><p><code>max\_birthdate</code></p>                                           | Earliest and latest birthdays of current directors                                                                         | <p><code><https://api2.redflagalert.net/v4/companies/?min_birthdate=1987-01-00&#x26;max_birthdate=1987-03-00></code></p><p>Returns all businesses with current directors born in January, February or March 1987.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Exact dates are not available for data protection reasons                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| <p><code>min\_employees</code></p><p><code>max\_employees</code></p>                                           | Range search on the reported number of employees for the business.                                                         | <p><code><https://api2.redflagalert.net/v4/companies/?min_employees=5&#x26;max_employees=50></code></p><p>Returns all companies with between 5 and 50 employees.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Can specify min or max parameters. To search within a range, specify both.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <p><code>min\_combined\_employees</code></p><p><code>max\_combined\_employees</code></p>                       | Range search across the estimated or actual number of employees, according to availability.                                | <p><code><https://api2.redflagalert.net/v4/companies/?min_combined_employees=50&#x26;max_combined_employees=100></code></p><p>Returns all companies with between 50 and 100 estimated or actual employees.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| <p><code>min\_incorporation\_date</code></p><p><code>max\_incorporation\_date</code></p>                       | Retrieve companies registered in a particular date range.                                                                  | <p><code><https://api2.redflagalert.net/v4/companies/?min_incorporation_date=1987-02-09></code></p><p>Return companies established on or after the 9th of February 1987.</p><p><code><https://api2.redflagalert.net/v4/companies/?min_incorporation_date=1977-01-01&#x26;max_incorporation_date=1987-12-31></code></p><p>Return companies established between 1977 and 1987.</p>                                                                                                                                                                                                                                                                                                                                                                                                                     | Supply valid dates in ISO-8601 standard YYYY-MM-DD format. Can specify min or max parameters. To search within a range, specify both.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| <p><code>min\_total\_assets</code></p><p><code>max\_total\_assets</code></p>                                   | Search on the last available total assets figure.                                                                          | <p><code><https://api2.redflagalert.net/v4/companies/?min_total_assets=50000&#x26;max_total_assets=10000></code></p><p>Returns companies with most recently reported assets of between £50k and £100k.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Can specify min or max parameters. To search within a range, specify both.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <p><code>min\_turnover</code></p><p><code>max\_turnover</code></p>                                             | Search on the last available turnover figure for a business.                                                               | <p><code><https://api2.redflagalert.net/v4/companies/?min_turnover=50000&#x26;max_turnover=100000></code></p><p>Returns businesses with last reported turnovers of between £50k and £100k.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Can specify min or max parameters. To search within a range, specify both.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <p><code>min\_combined\_turnover</code></p><p><code>max\_combined\_turnover</code></p>                         | Search across the estimated or actual turnover, according to availability.                                                 | <p><code><https://api2.redflagalert.net/v4/companies/?min_combined_turnover=50000&#x26;max_combined_turnover=100000></code></p><p>Returns all companies with between 50,000 and 100,000 estimated or actual turnover.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `min_credit_limit` `max_credit_limit`                                                                          | Range search on the `credit_limit` figure found in the `rfa_rating` section of a company                                   | `https://api2.redflagalert.net/v4/companies/?min_credit_limit=50000&max_credit_limit=100000`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `min_credit_score` `max_credit_score`                                                                          | Range search on the `credit_score` figure found in the `rfa_rating` section of a company (0 to 100)                        | `https://api2.redflagalert.net/v4/companies/?min_credit_score=75&max_credit_score=90`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `min_last_filed_accounts` `max_last_filed_accounts`                                                            | Range search on the date the company last filed their accounts in YYYY-MM-DD format                                        | `https://api2.redflagalert.net/v4/companies/?min_last_filed_accounts=2020-05-30`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `has_directorships`                                                                                            | Filters companies that have at least one directorship record.                                                              | `https://api2.redflagalert.net/v4/companies/?has_directorship=true`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| <p><code>sic\_section</code></p><p><code>sic\_section\_search\_type</code></p>                                 | Filter by the top-level SIC Section to which the company belongs.                                                          | <p><code><https://api2.redflagalert.net/v4/companies/?sic_section=F></code></p><p>Returns all construction businesses in the database.</p><p>Multiple section can be searched, in which case results will containe businesses that have any of the supplied codes:</p><p><code><https://api2.redflagalert.net/v4/companies/?sic_section=F,A></code></p><p>In order to only get results that match all of the supplied sectors, supply the 'sic\_section\_search\_type' parameter:</p><p><code><https://api2.redflagalert.net/v4/companies/?sic_section=F,A&#x26;sic_section_type=and></code></p>                                                                                                                                                                                                     | SIC section headings and letter codes given in [Appendix 2](https://developer.redflagalert.net/appendix/sic-sections). Companies may have several SIC sections if they are active in several areas; in this case, if any of the sections match then the company will be returned.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <p><code>sic\_code</code></p><p><code>sic\_code\_search</code></p><p><code>primary\_sic\_code</code></p>       | Filter on the exact SIC codes a company has.                                                                               | <p><code><https://api2.redflagalert.net/v4/companies/?sic_code=51519></code></p><p>Returns companies with the SIC code 51519.</p><p><code><https://api2.redflagalert.net/v4/companies/?sic_code=51519,51511></code></p><p>Returns companies with the SIC code 51519 or 51511.</p><p><code><https://api2.redflagalert.net/v4/companies/?sic_code=51519,51511&#x26;sic_code_search_type=and></code></p><p>Returns companies with at least the SIC codes 51519 and 51511 assigned.</p><p><code><https://api2.redflagalert.net/v4/companies/?primary_sic_code=51519></code></p><p>Returns companies whose primary SIC code is 51519.</p><p><code><https://api2.redflagalert.net/v4/companies/?primary_sic_code=51519,51511></code></p><p>Returns companies whose primary SIC code is 51519 or 51511.</p> | <p>You can supply multiple search parameters, comma separated in list.</p><p>By default, a search on a sic\_code will return companies that have any of the listed SIC codes. If you would like to see only companies that have all of the supplied SIC codes, supply the '<code>sic\_code\_search\_type</code>' parameter ate to 'and' (if not supplied, defaults to 'or').</p><p>SIC codes for companies are returned in order of priority, the primary SIC code being the first entry in the list. The primary SIC code itself is a searchable field. Multiple values can be supplied that will match a company that has any one of them as the primary SIC code. Only one value can be present for the 'primary\_sic\_code' therefore you cannot perform an 'and' search on this field as with 'sic code'.</p> |
| `rating`                                                                                                       | The Red Flag Alert credit rating currently assigned to this company.                                                       | <p>Returns companies with the specified Red Flag rating e.g:</p><p><code><https://api2.redflagalert.net/v4/companies/?rating=bronze></code></p><p>Returns companies with a 'Bronze' Red Flag rating.<br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | See [Appendix 3](https://developer.redflagalert.net/appendix/rfa-health-ratings) for a complete list of Red Flag Alert ratings and descriptions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `min_last_updated` `max_last_updated`                                                                          | Minimum and maximum date filters allowing you to narrow your query down to records updated within a specified time period. |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `tps_registered`                                                                                               | Whether or not the company is registered for the Telephone Preference Service.                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| filter\_name                                                                                                   |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| company\_type                                                                                                  |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| postcode\_area                                                                                                 |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| county                                                                                                         |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| town                                                                                                           |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| country                                                                                                        |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| telephone\_number                                                                                              |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| mortgage\_type                                                                                                 |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| mortgage\_holder                                                                                               |                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| min\_last\_updated                                                                                             | isoformat date                                                                                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| max\_last\_updated                                                                                             | isoformat date                                                                                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| min\_latest\_action\_date                                                                                      | isoformat date                                                                                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| max\_latest\_action\_data                                                                                      | isoformat date                                                                                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| address\_type                                                                                                  | "trading" or "registered"                                                                                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
