How To Use Maritime Port API For PHP

Maritime API

Maritime Port API for PHP

As a PHP developer, you may be looking for ways to enhance your applications and provide your users with valuable and relevant data. One tool that can help you achieve this is the Datalastic Maritime Port data API for PHP developers. This API provides access to information about maritime ports around the world, including details such as location, size, and activities and more.

By integrating this data into your PHP-based applications, you can provide your users with real-time information about ports and their operations. This can be useful for a variety of applications, such as logistics and supply chain management, shipping and transportation, and even tourism.

Using the Datalastic Maritime Port data API can save you time and effort in sourcing and integrating port data. It can also help you create more useful and informative applications for your users.

How does Maritime Port API work?

The maritime port REST API is a web-based API that allows users to access information about ports and their locations. To use the maritime Port API for PHP, you will need to sign up for an API key on Datalastic. Once you have an API key, you can make requests to the Maritime PortAPI using the following URL format:

https://api.datalastic.com/api/v0/port_find?api-key={YOUR_API_KEY}&{PARAMETER}={PARAMETER_VALUE}

To make a request, you will need to replace {YOUR_API_KEY} with your API key and {PARAMETER} and {PARAMETER_VALUE} with the parameters and values for your request.

Maritime Port API General Examples

The API supports several parameters, including port_name, country, city, and lat and lon for latitude and longitude coordinates.

For example, to search for ports in the United States, you could use the following URL:

https://api.datalastic.com/api/v0/port_find?api-key={YOUR_API_KEY}&country=US

 This would return a list of ports in the United States in JSON format. You can then parse the JSON data and use it in your PHP application.

The maritime port API is a valuable resource for PHP developers working on applications related to shipping and logistics. With this API, you can access up-to-date information about ports and their locations, making it easy to integrate this information into your PHP applications.

In addition to searching for ports by country, you can also use the name parameter to search for a specific port by name. For example, to search for the port of New York, you could use the following URL:

https://api.datalastic.com/api/v0/port_find?api-key={YOUR_API_KEY}&name=New%20York

 You can also combine multiple parameters in a single request. For example, to search for ports in the United States with the name “New York”, you could use the following URL:

https://api.datalastic.com/api/v0/port_find?api-key={YOUR_API_KEY}&country=US&name=New York

In addition to searching for ports by name and location, the maritime port API also allows you to search for ports by latitude and longitude coordinates. To do this, you can use the lat and lon parameters, along with a radius value in Nautical Miles. For example, to search for ports within 10NM of the coordinates 40.7128° N, 74.0059° W (which is the location of New York City), you could use the following URL:

https://api.datalastic.com/api/v0/port_find?api-key={YOUR_API_KEY}&lat=40.7128&lon=-74.0059&radius=10

The maritime port API provides you with data about ports and their locations, making it a valuable resource for PHP developers working on applications related to shipping and logistics. With the API, you can easily integrate this information into your PHP applications, providing your users with up-to-date information about ports and their locations.

API Response Example for PHP

{
 "data": [
 {
 "uuid": "17f4481e-801a-2c57-a356-e8ccf561f14f",
 "port_name": "LONDON",
 "country_iso": "GB",
 "country_name": "United Kingdom",
 "unlocode": "GBLON",
 "port_type": "Port",
 "lat": 51.49743,
 "lon": -0.04960075,
 "area_lvl1": "UK Coast & Atlantic",
 "area_lvl2": "North Sea"
 }
 ],
 "meta": {
 "duration": 0.0846065,
 "endpoint": "/api/v0/port_find",
 "success": true
 }
}

Using Maritime Port API you can easily implement port data in your PHP project. Feel free to check our API documentation to see the full detailed guide on Maritime Port API

How to use Port Data in PHP?

To use the maritime port API in PHP, you will need to use the file_get_contents function to make a request to the API URL and retrieve the JSON data. Here is an example of how to do this:

<?php
// Define API endpoint URL
$api_url = "https://api.datalastic.com/api/v0/port_find?api-key={YOUR_API_KEY}&name=New%20York&country=United%20States&fuzzy=1";
// Use cURL library to send a GET request to the API
$curl = curl_init();
curl_setopt_array($curl, array(
 CURLOPT_URL => $api_url,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
// Decode JSON response and access the data
$data = json_decode($response, true);
// Do something with the data, e.g. print it
print_r($data);
?> 

In this example, we are searching for ports in the United States with the name “New York”. You can modify the parameters to search for different ports and locations. Once you have made the request and decoded the JSON data, you can use it in your PHP application as needed.

The Datalastic Maritime Port data API is a valuable tool for PHP developers who want to integrate port data into their applications. This API provides access to information about maritime ports around the world. It allows developers to easily incorporate this data into their PHP-based applications. By using the Datalastic Maritime Port data API, PHP developers can save time and effort in sourcing and integrating port data. It can provide its users with valuable and up-to-date information about ports and their operations. If you are a PHP developer and are interested in using the Datalastic Maritime Port data API, you can learn more and subscribe to one of Datalastic’s plans.

Read Other Maritime Articles 

Flight API

Flight API

Access real-time, historical and future dates flight API to get flight status, location, delay, route data and more. Flight APIs of Aviation Edge are useful data tools for developers with global flight data and uptime rates of 99.9%.   Flight Tracking: Keep tabs...

Flight Tracker API

Flight Tracker API

Get real-time aircraft location and speed data with Aviation Edge Flight Tracker API. The flight tracking data allows you to monitor an aircraft’s real-time location, speed, and status throughout its route. The API uses REST which allows a clear and simple integration...

Flight Schedules API

Flight Schedules API

Flight Schedules API developed by Aviation Edge provides real-time, historical and future airport timetable data. Track departure and arrival schedules of airports worldwide. Alternatively, use an airline filter to track an airline’s flight schedule.   Flight number  ...

Why the Maritime API is a Must-Have?

Why the Maritime API is a Must-Have?

Maritime API, a revolution in the shipping and logistics sector, have transformed the way businesses in this industry operate. They grant access to a wealth of data about ships, their journeys, and intricate details that can be leveraged to streamline operations....

Find Ships In New York Port

Find Ships In New York Port

Finding ships in the New York Port is akin to tapping into the pulse of global commerce. Serving as the eastern gateway to the U.S., the NYC port is a bustling hub of trade. Its terminals show how important it is for worldwide links. In this article, we will identify...

Find 15 Major Maritime Ports in the World with API

Find 15 Major Maritime Ports in the World with API

Find major ports with API: In the world of maritime transportation, ports play a crucial role as key hubs for global trade and commerce. Identifying the major ports is essential for various stakeholders, including shipping companies, logistics providers, and port...