Addresses and validation through the API
What you can do
Section titled “What you can do”- Search places and streets with autocomplete, without knowing diacritics or the exact street type (“sosea pantelimon” returns “Șoseaua Pantelimon”).
- Get the postal code of an address, by street number where it exists.
- Validate a full address and get the correct form, the postal code and warnings.
- Validate an IBAN, a phone number and a Romanian tax ID (CUI).
Rivil Addresses works without the ERP. It has its own keys, managed in the service admin.
Keys and domains
Section titled “Keys and domains”Each site has a plan with per-minute and monthly limits and a list of allowed domains. There are two kinds of access:
| How | Where | What you send |
|---|---|---|
| site key | in the browser | the X-Site-Key header; the request must come from a listed domain |
| secret key | on your server | Authorization: Bearer ra_live_... |
The secret key never goes in the browser. For a form on a page, use the site key.
Places and counties
Section titled “Places and counties”GET /v1/places/search?q=sinaia&county=PH&limit=10
GET /v1/counties
Each place has id, county, postal_code (when the place has a single one), urban and location (locality-level coordinates).
Streets
Section titled “Streets”GET /v1/streets/search?q=sosea pantelimon&number=25&locality=București
{ "street": "Șoseaua Pantelimon", "locality": "București Sectorul 2", "postal_code": "021591", "match": "number"}match says how sure the code is: number (found by number), street (the street has a single code), number_ambiguous (the number fits several codes). When postal_code is empty, postal_codes lists the options and you can send number.
Postal codes by house number come from Poșta Română (2016) and cover Bucharest and cities over 50,000 inhabitants. The other streets in the country come from OpenStreetMap (source: openstreetmap): there the postal code is the locality’s, when the locality has a single one. location is the street’s point (precision: street) or, where OpenStreetMap has the number, the house’s (precision: point). Coverage of house numbers varies a lot between cities and villages. When you show OpenStreetMap data, keep “© OpenStreetMap contributors”.
Routes
Section titled “Routes”Routes use OpenStreetMap data for Romania. A point is { "lat": 45.75, "lng": 21.22 }, and mode is driving (default), walking, cycling or truck.
GET /v1/routes?from=45.75,21.22&to=46.77,23.59&optimize=shortest&steps=true returns distance_m, duration_s, geometry (GeoJSON LineString) and, with steps=true, turn-by-turn instructions, in Romanian or with language=en. optimize is fastest or shortest. With POST you send points, 2 to 25.
POST /v1/routes/matrix with sources and targets (up to 25 each) returns the distance and time matrix; a pair over 400 km is refused by the engine.
POST /v1/routes/optimize with start, stops and optional end returns the best stop order in order, plus the route.
POST /v1/routes/isochrone with center and minutes (up to 4 values, 1-60) returns the polygons of the areas reachable in those minutes.
Show “Map data: OpenStreetMap contributors” wherever you show a route. If the engine is down you get 503 with code: unavailable.
Zones belong to your site and are managed in the service admin, under Zones. A zone is a radius around a point, a list of localities and counties, postal code prefixes or a polygon (GeoJSON). It has a priority (low goes first) and an optional price and currency.
GET /v1/zones lists the active zones of the key’s site.
With the secret key (not the site key) you can also write them: POST /v1/zones creates, PUT /v1/zones/{id} replaces, DELETE /v1/zones/{id} deletes. The body has name, kind (radius, places, postal, polygon) and the fields of that kind (center + radius_m, place_ids or county_codes, postal_prefixes, polygon), plus optional active, priority, price, currency, color, note. Validation is the same as in the admin; a zone of another site returns 404.
GET /v1/zones/check?locality=Timisoara
Send lat and lng, or locality (with county, street, number), or postal_code. The response has inside, zone (the first match by priority), zones (all matches) and precision: point, locality (the locality’s coordinates, so approximate near a zone edge) or none (matched by locality, county or postal code, without coordinates).
The service has its own map tiles for Romania and a MapLibre style, so the map does not depend on an external provider:
const map = new maplibregl.Map({ container: 'map', style: 'https://adrese.rivil.app/map/style/light', // or /dark})You need maplibre-gl and pmtiles (the pmtiles:// protocol). The attribution “© OpenStreetMap contributors, Protomaps” must stay visible on the map; the style adds it in the corner.
In the administration, under Zones, you draw zones directly on the map: a radius (the center, then a point on the edge) or a polygon (corner by corner). You can also start from an isochrone, meaning everything reachable from a point within the minutes you choose, by road, and use it as the zone.
Cities of the world
Section titled “Cities of the world”GET /v1/world/cities/search?q=munchen&country=DE
Searches cities of over 15,000 inhabitants in any country, without diacritics, by local name and with small typos. country is optional (two-letter ISO code). Each result has name, country, region, population, timezone and location. Names are GeoNames’ English ones (“Munich”).
GET /v1/world/countries?q=roma
Countries, with code, capital, currency, phone code, postal code format and languages. World data has no streets or postal codes.
Address validation
Section titled “Address validation”GET /v1/addresses/validate?street=sosea pantelimon&number=25&locality=București&postal_code=021591
Send any of street, number, locality, county, postal_code. The response:
{ "status": "valid", "warnings": [], "normalized": { "street": "Șoseaua Pantelimon", "number": "25", "locality": "București Sectorul 2", "postal_code": "021591" }, "suggested_postal_code": "021591", "alternatives": []}status is valid, partial (not everything could be checked) or invalid. Warnings: locality_not_found, locality_missing, county_mismatch, street_not_found, street_source_not_available, postal_code_mismatch, number_needed_for_postal_code, number_matches_several_codes.
IBAN, phone, tax ID
Section titled “IBAN, phone, tax ID”GET /v1/validate/iban?value=RO49 AAAA 1B31 0075 9384 0000: checks length and checksum; for Romanian IBANs it also returns the bank.GET /v1/validate/phone?value=0722 123 456&country=RO: returns the international form (e164), the national form and the type (mobile,fixed,special).GET /v1/validate/cui?value=RO14399840: checks the control digit. When the service is linked to Rivil Firme,lookupalso returns the company data; otherwiselookup.statusisunavailableand validation relies on the control digit.
An invalid response has valid: false and a stable reason, for example bad_checksum or wrong_length.
From your site, through the ERP
Section titled “From your site, through the ERP”With a Rivil account you do not need a separate key for addresses: your site calls /api/site/v1/addresses/places, /streets and /validate with its site key, and the responses have the same shape (validate returns suggested_postal_code and normalized). The routes are described in the site API.
Inside the ERP the service works on its own in a few places:
- Store: a shipping zone can be set by county, by postal code prefixes or by a GeoJSON polygon (pasted from the zones drawn here). The polygon is matched on the locality’s coordinates, so near the edge the result is approximate.
- Locations: latitude and longitude are filled from the address on save, in Romania only.
- AWB: the recipient’s county, locality and any missing postal code are corrected before the shipment goes to the courier; the street stays as the customer wrote it.
If the service does not answer, nothing is blocked: the order, the location and the AWB carry on with the data as it is.
Limits
Section titled “Limits”Over the per-minute limit you get 429 with code: rate_limited; over the monthly one, 429 with code: quota_exceeded. Start searching from 2-3 characters and wait 150-200 ms after the last keystroke.