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 

How Classification Societies Influence Dry Dock Scheduling?

How Classification Societies Influence Dry Dock Scheduling?

In the maritime world, the safety and efficiency of a vessel are paramount. This is where the roles of classification societies and dry dock schedules become pivotal. Both elements are essential cogs in the maritime machinery, ensuring that ships not only meet global...

Dry Dock Schedules Data: Discover Dates & Details

Dry Dock Schedules Data: Discover Dates & Details

In the world of maritime operations, staying ahead in the game means keeping your vessel in top-notch condition. But how can you ensure this without a solid grasp of your ship's maintenance schedule? This is where the importance of understanding ship dry dock...

Dry Dock Dates Data:Navigating Fleet Maintenance

Dry Dock Dates Data:Navigating Fleet Maintenance

In the complex and ever-evolving maritime industry, staying ahead in maintenance schedules is not just about compliance; it's a critical component of operational efficiency and safety. Datalastic's Dry Dock Dates Vessels API emerges as a beacon of innovation, offering...

How To Get Data about Vessel Engines Performance?

How To Get Data about Vessel Engines Performance?

  In the vast and ever-evolving maritime industry, the performance of a vessel's engine stands as a pivotal factor that directly influences its speed, efficiency, and overall operational capacity. Understanding this dynamic is crucial for ship operators, owners,...

Ship Owners Types: A Comprehensive Overview

Ship Owners Types: A Comprehensive Overview

Ship owners play a pivotal role in the maritime industry. They range from individuals to expansive corporations, responsible for hiring crews and managing the ship's journey. In this article we will unveiling how to uncover data about these owners and pinpoint the...