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
For detailed instructions on generating an access token, please refer to the Authentication guide.
After calling the https://auth.celitech.net/oauth2/token
endpoint, 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());
}
}