Get Profile Phones Cache
GET/v1/caches/phones
Downloads a country-specific gzipped TSV file (.tsv.gz) of phone profile data. The response is a 307 redirect to a signed URL that expires in 30 seconds.
The file contains seven tab-separated columns: phone number, reputation level (SPAM, FRAUD, or NEUTRAL), reputation category ID (integer; may be empty), display name, display description, display detail, and display image.
Terms of usage of API: Before you use the Hiya API you must sign and agree with our terms of use that should have been provided in a different document. Use of the Hiya API requires partners to include Hiya's use of data policy either in your Terms of Service, or by making the policy accessible to end users in your app via a screen or link. This is necessary for GDPR and other privacy laws. The content or the link will be provided to you. Hiya is not liable for the use of the API responses.
Introduction
This document describes the usage of the Hiya Protect Cache API to support local server caches of phone profile data. API integrators may download a country-specific set of phone numbers with their associated reputation levels, categories, and display information.
Get Profile Phones Cache
Successful requests to the API will return an HTTP status code of 307 'Temporary Redirect'. This response will include a signed URL in the Location header as well as in the body of the request.
The Integrator will need to perform a GET request using the returned URL within 30 seconds, after which the URL will expire and become unusable. In this case, the integrator must make a new API request.
Successful GET requests will return an HTTP status code of 200 OK. Requests made to an expired URL will return a 403 Forbidden response. In very rare cases requests may return a 404 Unknown response. In this case, there has been an error in the process generating the cache file. You may retry the API request after an hour.
The returned cache filename is not meant to be meaningful, and can change over time. Do not rely on a filename for any local comparison operations.
The file will be a gzipped TSV file (.tsv.gz) with seven tab-separated columns:
- Phone Number: formatted with a forward-slash between country code and national part (e.g.
91/9876543210) - Reputation Level: One of three values:
FRAUD: A call that Hiya predicts is likely intended to harm the user, such as attempting to steal identity, collect banking or credit card information, or commit extortion.SPAM: A nuisance call that does not rise to the level of FRAUD.NEUTRAL: The reputation was neutral. Hiya cannot ascertain with 100% accuracy that the call is safe — do not display it as verified or zero-risk.
- Reputation Category: This information will not appear for all numbers in the returned file, as the Hiya Protect solution cannot make a definitive categorization determination for every call analyzed. The reputation category is provided as an integer in the returned file. The current mapping of integer to category is listed in the following table. An integrator's use of these categorizations is entirely at their discretion.
- Display Name: caller or business name; may be empty
- Display Description: additional description; may be empty
- Display Detail: supplementary detail; may be empty
- Display Image: URL of an associated image; may be empty
| Integer | Reputation Category |
|---|---|
| 3 | Debt Collector |
| 4 | Political Call |
| 5 | Nonprofit Call |
| 6 | Telemarketer |
| 7 | Survey Call |
| 8 | Scam |
| 9 | Extortion Scam |
| 10 | Robocaller |
| 1000 | Phishing |
| 1001 | Toll Free |
| 1002 | Stolen Identity |
| 1003 | IRS Scam |
| 1004 | Tax Scam |
| 1005 | Tech Support Scam |
| 1006 | Vacation Scam |
| 1007 | Lucky Winner Scam |
Hiya reserves the right to add new reputation categories in the future, so integrators must gracefully handle cases when a reputation category integer not in the current mapping is returned. If you do receive an unexpected reputation category integer, feel free to reach out to Hiya for an updated table.
Supported Countries
The country query parameter is required and must be uppercase. Supported ISO 3166-1 alpha-2 country codes:
AF, BD, BR, BT, DZ, EG, GH, HK, ID, IL, IN, IQ, JO, JP, KE, KG, KH, KZ, LA, LB, LK, MA, MM, MY, NG, NP, PG, PH, PK, PS, SA, SG, TH, TN, TR, TW, VN, YE, ZA
Example
91/9876543210 SPAM 6 Example Telemarketer
91/9123456789 FRAUD 8 Scam Caller
91/9000000001 SPAM Company Name
eTags
When following the redirected URL returned in the Location header from a 307 response, you can utilize ETags to prevent re-downloading the entire cache if it hasn't changed since the last time you downloaded it.
A standard flow for utilizing ETags is:
- Store the ETag from your first request
- Request /v1/caches/phones?country=IN
- Follow 307 Location signed url to download the cache
- Read the HTTP response header called
ETagfrom the response (after following redirect) and store it locally
- Add the ETag on subsequent requests in
If-None-MatchHTTP header when following the 307 redirect
- Request /v1/caches/phones?country=IN
- Follow 307 Location signed url with
If-None-Match: YOUR_ETAG_HEREHTTP header to download the cache - If the cache contents haven't changed, you will receive 304 Not Modified response
- If the cache contents have changed, you will receive the new cache contents and an updated
ETagresponse header value (which you store locally for next request)
Some HTTP clients might do automatic redirection following the 307 response, with clients like this, you won't need to handle the multiple requests in your code. Here is a Python requests library example.
response = requests.get(
'https://api.hiyaapi.com/v1/caches/phones',
params={'country': 'IN'},
auth=HTTPBasicAuth(credential_id, credential_secret),
headers={'If-None-Match': etag},
allow_redirects=True
)
if response.status_code == 304:
print('Cache not changed')
else:
with open(cache_filename, "wb") as f:
f.write(response.content)
print('Cache changed')
etag = response.headers.get('ETag')
Related caches
- See Spammer Cache for spam and fraud numbers only (no display data, no country filter) — use this if you don't need branding or display fields.
- See Branded Phones Cache for branded display names only (no reputation data) — this is a Hiya Connect cache, available independently of Protect.
Query Parameters
ISO 3166-1 alpha-2 country code (e.g.
IN
BR
PH
Possible values: Value must match regular expression ^[A-Z]{2}$
Responses
- 307
- 400
- 401
- 403
- 404
- 408
- 410
- 429
- 500
Successfully retrieved signed URL for the profile phones cache file
Headers
Location
string
Contains a signed URL (which expires in 30 seconds) from which you will download the cache file.
Bad Request - The country code is missing, invalid, or not in the supported list.
Unauthorized - The API Key is invalid or missing.
Forbidden - The API Key doesn't have the necessary authorization to access this resource.
Not Found - The requested country is not supported for this subproduct.
Request Timeout - A complete request was not received by the server within its allotted timeout period. It's safe to retry.
Gone - You must stop calling this API permanently once you receive this status code
Too Many Requests - The number of requests within a given time period was exceeded.
Internal Server Error - The server has experienced an unexpected condition and is unable to process the request