Authentication overview
AIS Hub secures access to its maritime data APIs through a straightforward authentication mechanism centered on API keys. This method requires developers to include a unique, secret key with each request to the AIS Hub API. API keys serve as a token that identifies the calling application or user and verifies their authorization to access the requested data, such as real-time vessel positions or historical track data. The system is designed to provide secure, controlled access while maintaining ease of integration for developers working with AIS Hub's API services. Using API keys is a common practice for authenticating access to web services, offering a balance between security and operational simplicity for service consumers.
When an API request is made to AIS Hub, the system checks for the presence and validity of the provided API key. If the key is missing or invalid, the request is rejected, preventing unauthorized data retrieval. This mechanism is applied across all of AIS Hub's core products, including the AIS API, historical data retrieval, and real-time data streams, as detailed in the official AIS API documentation.
Supported authentication methods
AIS Hub primarily supports API key authentication for accessing its services. This method involves generating a unique, alphanumeric string that acts as a secret token. When making requests, this key is appended as a query parameter in the API endpoint URL. This approach offers a direct and easily implementable method for developers to authenticate their applications.
The table below outlines the primary authentication method supported by AIS Hub:
| Method | When to Use | Security Level |
|---|---|---|
| API Key | All API requests for real-time and historical AIS data | Moderate (when properly managed and transmitted over HTTPS) |
While API keys provide a convenient authentication mechanism, it is crucial to manage them with care to prevent unauthorized access. Best practices include transmitting keys over secure channels (HTTPS), restricting their exposure in client-side code, and employing revocation mechanisms if a key is compromised. The simplicity of API key authentication makes it suitable for a wide range of applications, from server-side integrations to client applications, provided adequate security measures are in place.
Getting your credentials
To obtain your API key for AIS Hub, you must register for an account on the official AIS Hub website. The process typically involves:
- Account Registration: Navigate to the AIS Hub homepage and sign up for a new account. This usually requires providing an email address and creating a password.
- Dashboard Access: Once registered and logged in, you will be directed to your personal dashboard or account management area.
- API Key Generation: Within your dashboard, there will typically be a section dedicated to API access or developer settings. Here, you should find an option to generate or view your API key. For example, AIS Hub's API documentation confirms that keys are provided upon account creation for both free and paid plans.
- Key Retrieval: Your unique API key will be displayed. It is critical to copy and store this key securely, as it is your primary means of authenticating with the AIS Hub API. For security, some platforms only display the key once upon generation, so immediate storage is advisable.
AIS Hub offers a free tier that includes 5,000 requests per month, which also requires an API key. This allows developers to test the API and integrate it into their applications before committing to a paid plan. The API key remains consistent across different service tiers, but access limits and available data might vary according to your subscription level.
Authenticated request example
Once you have obtained your API key from your AIS Hub account, you can use it to make authenticated requests to the API. The API key is appended as a query parameter, typically named apikey or similar, to the API endpoint URL. All requests must be made over HTTPS to ensure the secure transmission of your API key and data.
Here's a generalized example of how to make an authenticated request, assuming your API key is YOUR_API_KEY and you are querying for vessel data:
GET https://data.aishub.net/ws.php?format=json&output=api&vesselid=220456000&zoom=14&apikey=YOUR_API_KEY HTTP/1.1
Host: data.aishub.net
User-Agent: YourApplication/1.0
Accept: application/json
In this example:
https://data.aishub.net/ws.phpis the base API endpoint.format=jsonspecifies the desired response format.output=apiindicates the specific API method.vesselid=220456000is an example query parameter for a specific vessel.apikey=YOUR_API_KEYis where you replaceYOUR_API_KEYwith your actual key.
It is important to consult the AIS Hub API documentation for specific endpoint details, available parameters, and response structures related to the particular data you wish to retrieve. The documentation also provides examples in various programming languages like PHP, Python, and JavaScript, demonstrating how to construct these authenticated requests programmatically.
Security best practices
Securing your API keys and calls to the AIS Hub API is crucial to prevent unauthorized access and protect your data. Adhering to established security best practices can significantly mitigate risks associated with API key management:
- Always Use HTTPS: All communication with the AIS Hub API must be conducted over HTTPS. This encrypts the data in transit, protecting your API key from interception by malicious actors. Without HTTPS, your API key could be exposed in plain text if intercepted on an unsecured network. The Internet Engineering Task Force (IETF) provides extensive information on securing web communication through HTTP over TLS.
- Protect Your API Keys: Treat your API keys as sensitive credentials, similar to passwords. Avoid embedding them directly in client-side code (e.g., JavaScript in a web browser) where they can be easily exposed. Instead, use a backend server to make API calls, keeping your API key secure on the server.
- Environment Variables for Keys: Store API keys in environment variables rather than hardcoding them directly into your application's source code. This practice prevents keys from being committed to version control systems (like Git) and makes it easier to manage different keys for development, staging, and production environments.
- Restrict API Key Permissions (if applicable): While AIS Hub's API keys typically grant access based on your subscription, if there were options for granular permissions, you would configure keys with the minimum necessary privileges. This principle of least privilege limits the potential damage if a key is compromised.
- Regularly Rotate Keys: Periodically rotate your API keys. This means generating a new key and updating your applications, then revoking the old key. Regular rotation reduces the window of opportunity for a compromised key to be exploited.
- Monitor API Usage: Keep an eye on your API usage patterns. Unusual spikes in requests or calls from unexpected locations could indicate that your API key has been compromised. AIS Hub's dashboard may offer usage statistics to help with this monitoring.
- Implement Rate Limiting and Quotas: While AIS Hub enforces its own rate limits based on your plan, implementing client-side rate limiting can add an extra layer of protection, preventing abuse, and helping you stay within your allocated request limits, thereby avoiding unexpected charges.
By diligently applying these practices, developers can ensure that their integration with the AIS Hub API remains secure and resilient against common vulnerabilities.