Common Port Numbers API
API is published to Rapid API Marketplace.
In order to use it, you have to register at Rapid API and sign up for CommonPortNumbers API.
API contains only one HTTP GET endpoint called commonports.
The URL is "https://commonportnumbers.p.rapidapi.com/commonportnames".
API Parameters
Required parameters have to be passed in the request header:
- X-RapidAPI-Key
- X-RapidAPI-Host
- port
- service
- protocol
Response
Response is a JSON array with the following properties:
[ { "ServiceName": "domain", "PortNumber": "53", "PortType": "System Port", "TransportProtocol": "tcp", "Description": "Domain Name Server", "Reference": "N/A", "Source": "Internet Assigned Numbers Authority (IANA)", "Notes": "" } ]
Code Samples
Rapid API contains myriad of code samples to help you to get started much faster.
Here are C#,PowerShell & Python (yes, just those cause I like them =P) samples for your reference.
C#
var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://commonportnumbers.p.rapidapi.com/commonportnames?port=53&protocol=tcp"), Headers = { { "X-RapidAPI-Key", "SIGN-UP-FOR-KEY" }, { "X-RapidAPI-Host", "commonportnumbers.p.rapidapi.com" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); }
PowerShell
$headers= $headers.Add("X-RapidAPI-Key", "SIGN-UP-FOR-KEY") $headers.Add("X-RapidAPI-Host", "commonportnumbers.p.rapidapi.com") $response = Invoke-RestMethod -Uri 'https://commonportnumbers.p.rapidapi.com/commonportnames?port=53&protocol=tcp' -Method GET -Headers $headers
Python
import http.client conn = http.client.HTTPSConnection("commonportnumbers.p.rapidapi.com") headers = { 'X-RapidAPI-Key': "SIGN-UP-FOR-KEY", 'X-RapidAPI-Host': "commonportnumbers.p.rapidapi.com" } conn.request("GET", "/commonportnames?port=53&protocol=tcp", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
Get Started at RapidAPI Quick Start Guide.