Getting started with Reverse Geocoding🔗
Reverse geocoding converts latitude and longitude to location details such as countries, cities, and addresses. Follow these steps to set it up.
Step 1: Get your Resource Key🔗
You'll need a Resource Key to access our reverse geocoding service. Follow the Resource Key guide to create one. Make sure your Resource Key includes at least the Country field.
Step 2: Install the library🔗
Step 3: Set up your pipeline🔗
The pipeline is how you connect to 51Degrees APIs (learn more in basic pipeline description and Pipeline). Use the Resource Key you created in step 1.
Step 4: Add your coordinates🔗
You need to provide latitude and longitude coordinates (called evidence). Use these specific keys:
- query.51D_pos_latitude
- query.51D_pos_longitude
The keys aren't case-sensitive.
Step 5: Run the query🔗
Call process() to start the reverse geocoding lookup.
Step 6: Get your results🔗
Read the results from the flow data once process() has finished, as the snippets below show. Each property says whether it has a value (HasValue in C#, hasValue() in Java, hasValue in Node.js and PHP, and has_value() in Python). If it does, its value is the result. If not, its no value message says why.
Find complete working code examples on GitHub for each language:
Troubleshooting🔗
Having issues? Here are common problems and fixes:
Resource Key problems🔗
"Resource Key not found" error: Your Resource Key is invalid. Create a new one with the properties you need.
Properties missing from results: Your Resource Key might not have access to location properties. Check what your key can access at https://configure.51degrees.com/YOUR_RESOURCE_KEY or create a new key with the right permissions.
Wrong evidence keys🔗
If you get an error about missing evidence, check you're using the correct keys:
- query.51d_pos_latitude
- query.51d_pos_longitude
Wrong keys get ignored, which can cause errors if you don't have any valid evidence.
