0% found this document useful (0 votes)
19 views

Free API

Uploaded by

sumitnikam03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Free API

Uploaded by

sumitnikam03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

FreeAPI.

md 2024-07-07

Here are some options for free APIs with generous or unlimited access for travel data, payment processing,
and mapping services:

Travel APIs

1. OpenTripMap API

Features: Points of interest, attractions, restaurants, and more.


Free Tier: Generous free tier with a limited number of requests per day.
Website: OpenTripMap API

2. REST Countries API

Features: Information about countries, such as population, area, and borders.


Free Tier: Unlimited access.
Website: REST Countries

Payment Gateways

1. Stripe (Test Environment)

Features: Payment processing, subscription billing, and more.


Free Tier: While the live version has transaction fees, the test environment is free and unlimited
for development purposes.
Website: Stripe

2. PayPal (Test Environment - Sandbox)

Features: Payment processing, invoicing, and more.


Free Tier: The Sandbox environment is free and unlimited for development and testing.
Website: PayPal Developer

Mapping Services

1. OpenStreetMap (OSM)

Features: Free and open-source map data.


Free Tier: Completely free to use, but you might need to use a third-party provider for hosted
API services.
Website: OpenStreetMap

2. Leaflet

Features: Open-source JavaScript library for mobile-friendly interactive maps.


Free Tier: Completely free to use.
Website: Leaflet

Example Integration

Here’s an example of integrating the OpenTripMap API in a .NET Core project:

1/3
FreeAPI.md 2024-07-07

1. Set up the HttpClient in your Startup.cs:

public void ConfigureServices(IServiceCollection services)


{
services.AddHttpClient<IOpenTripMapService, OpenTripMapService>(client =>
{
client.BaseAddress = new Uri("https://api.opentripmap.com/0.1/en/");
});

services.AddControllersWithViews();
}

2. Create the OpenTripMap service:

Services/IOpenTripMapService.cs:

using System.Threading.Tasks;

public interface IOpenTripMapService


{
Task<string> GetPlacesAsync(string query);
}

Services/OpenTripMapService.cs:

using System.Net.Http;
using System.Threading.Tasks;

public class OpenTripMapService : IOpenTripMapService


{
private readonly HttpClient _httpClient;

public OpenTripMapService(HttpClient httpClient)


{
_httpClient = httpClient;
}

public async Task<string> GetPlacesAsync(string query)


{
var apiKey = "YOUR_API_KEY";
var response = await _httpClient.GetAsync($"places/geoname?name=
{query}&apikey={apiKey}");

response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}

2/3
FreeAPI.md 2024-07-07

3. Use the service in your controller:

Controllers/HomeController.cs:

using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

public class HomeController : Controller


{
private readonly IOpenTripMapService _openTripMapService;

public HomeController(IOpenTripMapService openTripMapService)


{
_openTripMapService = openTripMapService;
}

public async Task<IActionResult> Index(string query)


{
if (!string.IsNullOrEmpty(query))
{
var places = await _openTripMapService.GetPlacesAsync(query);
ViewBag.Places = places;
}

return View();
}
}

By using these free APIs, you can implement a wide range of functionalities for your "Travel Genie" project
without incurring costs. Let me know if you need further details or help with other integrations!

3/3

You might also like