-
Notifications
You must be signed in to change notification settings - Fork 0
API Integration
HlexNC edited this page Feb 9, 2026
·
1 revision
Setup and usage guide for all external APIs consumed by iTravel.
iTravel integrates three external REST APIs and one SDK. All HTTP APIs are accessed through Retrofit 2 singleton clients managed by RetrofitClient.java.
| Service | Base URL | Auth Method | Used For |
|---|---|---|---|
| REST Countries | https://restcountries.com/v3.1/ |
None (public) | Country metadata and flags |
| Unsplash | https://api.unsplash.com/ |
Authorization header |
Location photos |
| OpenWeatherMap | https://api.openweathermap.org/data/2.5/ |
appid query param |
Weather overlays |
| Google Maps SDK | N/A (native SDK) | API key in manifest | Map display and location |
No API key required.
GET /v3.1/all?fields=name,flags,region
GET /v3.1/name/{name}?fields=name,flags,region
{
"name": { "common": "Germany", "official": "Federal Republic of Germany" },
"flags": { "png": "https://flagcdn.com/w320/de.png", "alt": "..." },
"region": "Europe"
}- Register at unsplash.com/developers
- Create an application to get an Access Key
- Set in
Constants.java:public static final String UNSPLASH_ACCESS_KEY = "your-key-here";
GET /photos/random
Header: Authorization: Client-ID {ACCESS_KEY}
Params: count, query, orientation
{
"id": "abc123",
"urls": { "raw": "...", "regular": "...", "thumb": "..." },
"location": { "name": "Paris", "latitude": 48.8566, "longitude": 2.3522 }
}- Register at openweathermap.org/api
- Generate an API key (free tier supports current weather)
- Set in
Constants.java:public static final String WEATHER_API_KEY = "your-key-here";
GET /weather?lat={lat}&lon={lon}&appid={key}&units=metric
{
"weather": [{ "icon": "01d", "description": "clear sky" }],
"main": { "temp": 22.5, "humidity": 45 }
}https://openweathermap.org/img/wn/{icon}@2x.png
- Enable Maps SDK for Android in Google Cloud Console
- Create an API key restricted to your app's package name and SHA-1 fingerprint
- Add to
AndroidManifest.xml:<meta-data android:name="com.google.android.geo.API_KEY" android:value="your-key-here" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />| Component | Usage |
|---|---|
SupportMapFragment |
Embedded map in DiscoverFragment
|
FusedLocationProviderClient |
Current user location for GPS validation |
Location.distanceTo() |
Proximity check in GPSValidator
|
RetrofitClient.java provides three lazy-initialized singleton instances:
RetrofitClient.getCountriesClient() // → CountriesApi
RetrofitClient.getUnsplashClient() // → UnsplashApi
RetrofitClient.getWeatherClient() // → WeatherApiAll clients use:
-
GsonConverterFactoryfor JSON serialization -
OkHttpwith optionalHttpLoggingInterceptor(debug builds)
| API | Free Tier Limit | Notes |
|---|---|---|
| REST Countries | Unlimited | Public, no key |
| Unsplash | 50 requests/hour | Demo key; apply for production |
| OpenWeatherMap | 60 calls/minute | 1,000 calls/day on free plan |
| Google Maps SDK | 28,000 map loads/month | Free within $200/month credit |
Warning
Production Deployment: Apply for higher-tier Unsplash access and consider caching strategies to stay within rate limits.
iTravel — Von Travelern für Traveler · GitHub · Deggendorf Institute of Technology
Links