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 

Access Any Vessel With IMO API

Access Any Vessel With IMO API

As a developer, you understand the importance of reliable and efficient APIs in your projects. Therefore, IMO API, also known as the International Maritime Organization API, is a comprehensive database of global shipping information. It provides access to a wide range...

Maritime API: 10 Popular Questions And Their Answers

Maritime API: 10 Popular Questions And Their Answers

A maritime API, or application programming interface, is a set of protocols and tools that allows developers to build software applications that interact with maritime data. These APIs enable developers to access and integrate maritime data from various sources, such...

How to use Datalastic API to optimize your shipping routes?

If you aare already tracking your shipping routes, you may wonder how to make it better.  Talk aboutMaritime Data Importance  Talk about contact flow of data, update data  What is maritime API?  Ways to optimize shipping routes with Maritime API:  1. Update shipping...

Unleashing The Power Of The Vessel API In Java

Unleashing The Power Of The Vessel API In Java

If you're a Java developer looking to integrate marine logistics functionality into your projects, then the Vessel API is an excellent option to consider. In this article, we'll take a look at why Java is a good choice for working with the Vessel API As well as, the...

Historical Vessel Location API for Java

Historical Vessel Location API for Java

Historical vessel location API is a Java-based application programming interface (API) that enables developers to access and retrieve historical data for a specific location. Furthermore, the API utilizes various sources of data, such as weather stations and satellite...

Why the vessel tracking system is important?

Why the vessel tracking system is important?

The vessel tracking system is an important tool for monitoring the position and movement of ships at sea. This system allows shipping companies, port authorities, and other stakeholders to track the location and status of vessels in real-time, ensuring the safety and...