Introduction
CELITECH API allows you to integrate mobile data connectivity into your applications, products, or services. This guide will walk you through the essential steps to get started with the API, including a detailed explanation of the authentication process.
Step-by-Step Integration
Step 1: Obtain Your API Credentials
- Log in to your CELITECH dashboard.
- Navigate to the Developers section on the left.
- Click on API CREDENTIALS
- Here, you will find your Client Id and Client Secret. Copy them as you will need them for authentication.
Step 2: Generate Token
To generate a token, follow these two steps:
1. Make a POST Request to Obtain an Access Token
Use the following Depending on your choice of programming language, making sure to replace YOUR_CLIENT_ID
and YOUR_CLIENT_SECRET
with your actual client credentials.
- cURL
- PHP
- Ruby
- C#
- Node.js
- Python
- Go
- Java
curl -X POST "https://auth.celitech.net/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
<?php
$client_id = "YOUR_CLIENT_ID";
$client_secret = "YOUR_CLIENT_SECRET";
$url = "https://auth.celitech.net/oauth2/token";
$postFields = [
"grant_type" => "client_credentials",
"client_id" => $client_id,
"client_secret" => $client_secret
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if (curl_errno($ch)) {
// Handle error
echo 'Curl error: ' . curl_error($ch);
} else {
// Print the result
echo $result;
}
curl_close($ch);
?>
require 'net/http'
uri = URI('https://auth.celitech.net/oauth2/token')
res = Net::HTTP.post_form(uri, 'grant_type' => 'client_credentials', 'client_id' => 'YOUR_CLIENT_ID', 'client_secret' => 'YOUR_CLIENT_SECRET')
puts res.body
using System.Net.Http;
var client = new HttpClient();
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", "YOUR_CLIENT_ID"),
new KeyValuePair<string, string>("client_secret", "YOUR_CLIENT_SECRET")
});
var response = await client.PostAsync("https://auth.celitech.net/oauth2/token", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
const axios = require('axios');
axios.post('https://auth.celitech.net/oauth2/token', 'grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET', {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then((response) => {
console.log(response.data);
});
import requests
response = requests.post('https://auth.celitech.net/oauth2/token', data={
'grant_type': 'client_credentials',
'client_id': 'YOUR_CLIENT_ID',
'client_secret': 'YOUR_CLIENT_SECRET'
})
print(response.json())
package main
import (
"net/http"
"net/url"
"strings"
"fmt"
"io/ioutil"
)
func main() {
data := url.Values{}
data.Set("grant_type", "client_credentials")
data.Set("client_id", "YOUR_CLIENT_ID")
data.Set("client_secret", "YOUR_CLIENT_SECRET")
response, err := http.Post("https://auth.celitech.net/oauth2/token", "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
if err != nil {
panic(err)
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
HttpURLConnection con = (HttpURLConnection) new URL("https://auth.celitech.net/oauth2/token").openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setDoOutput(true);
String data = "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET";
con.getOutputStream().write(data.getBytes());
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
2. Copy the Access Token from the Response
After executing the command, you will receive a JSON response that includes the access token. It will look something like this:
{
"access_token": "YOUR_ACCESS_TOKEN",
"token_type": "Bearer",
"expires_in": 3600
}
Copy the value of access_token
for use in subsequent requests. Make sure to keep this token secure, as it allows access to protected resources.
Step 3: Purchase an eSIM
Use the following Depending on your choice of programming language, making sure to provide the access token retrieved from the previous step.
- cURL
- PHP
- Ruby
- C#
- Node.js
- Python
- Go
- Java
curl -i -X POST \
https://api.celitech.net/v1/purchases \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"destination": "FRA",
"dataLimitInGB": 1,
"startDate": "2024-01-01",
"endDate": "2024-01-31"
}'
<?php
$token = "<YOUR_TOKEN_HERE>";
$url = "https://api.celitech.net/v1/purchases";
$jsonData = json_encode([
"destination" => "FRA",
"dataLimitInGB" => 1,
"startDate" => "2024-01-01",
"endDate" => "2024-01-31"
]);
$headers = [
"Authorization: Bearer " . $token,
"Content-Type: application/json"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
// Handle error
echo 'Curl error: ' . curl_error($ch);
} else {
// Print the response
echo $response;
}
curl_close($ch);
?>
require 'json'
require 'uri'
require 'net/http'
require 'openssl'
url = URI('https://api.celitech.net/v1/purchases')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer <YOUR_TOKEN_HERE>'
request.body = {
destination: 'FRA',
dataLimitInGB: 1,
startDate: '2024-01-01',
endDate: '2024-01-31'
}.to_json
response = http.request(request)
puts response.read_body
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text;
using Newtonsoft.Json.Linq;
public class Program
{
private readonly IHttpClientFactory _httpClientFactory;
public static async Task Main(string[] args)
{
var client = _httpClientFactory.CreateClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer <YOUR_TOKEN_HERE>");
JObject json = JObject.Parse(@"{
destination: 'FRA',
dataLimitInGB: 1,
startDate: '2024-01-01',
endDate: '2024-01-31'
}");
var postData = new StringContent(json.ToString(), Encoding.UTF8, "application/json");
var request = await client.PostAsync("https://api.celitech.net/v1/purchases", postData);
var response = await request.Content.ReadAsStringAsync();
Console.WriteLine(response);
}
}
import fetch from 'node-fetch';
async function run() {
const resp = await fetch(
`https://api.celitech.net/v1/purchases`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer <YOUR_TOKEN_HERE>'
},
body: JSON.stringify({
destination: 'FRA',
dataLimitInGB: 1,
startDate: '2024-01-01',
endDate: '2024-01-31'
})
}
);
const data = await resp.json();
console.log(data);
}
run();
import requests
url = "https://api.celitech.net/v1/purchases"
payload = {
"destination": "FRA",
"dataLimitInGB": 1,
"startDate": "2024-01-01",
"endDate": "2024-01-31"
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <YOUR_TOKEN_HERE>"
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data)
package main
import (
"fmt"
"bytes"
"net/http"
"io/ioutil"
)
func main() {
reqUrl := "https://api.celitech.net/v1/purchases"
var data = []byte(`{
"destination": "FRA",
"dataLimitInGB": 1,
"startDate": "2024-01-01",
"endDate": "2024-01-31"
}`)
req, _ := http.NewRequest("POST", reqUrl, bytes.NewBuffer(data))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <YOUR_TOKEN_HERE>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import java.net.*;
import java.net.http.*;
import java.util.*;
public class App {
public static void main(String[] args) throws Exception {
var httpClient = HttpClient.newBuilder().build();
var payload = String.join("\n"
, "{"
, " \"destination\": \"FRA\","
, " \"dataLimitInGB\": 1,"
, " \"startDate\": \"2024-01-01\","
, " \"endDate\": \"2024-01-31\""
, "}"
);
var host = "https://api.celitech.net";
var pathname = "/v1/purchases";
var request = HttpRequest.newBuilder()
.POST(HttpRequest.BodyPublishers.ofString(payload))
.uri(URI.create(host + pathname ))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer <YOUR_TOKEN_HERE>")
.build();
var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Step 4: Handling Responses
Responses are returned in JSON format. Handle them according to your application's needs.
Additional Resources
- API Reference: Detailed information about endpoints, parameters, and responses can be found in the API Reference.
- Support: For further assistance, contact CELITECH support.
Conclusion
By following this guide, you should be able to integrate CELITECH's mobile data connectivity into your application. Explore the full API documentation for more advanced features and capabilities.