DEV Community

Cover image for Open APIs in Telecom: Your Ticket to the Developer’s Playground

Open APIs in Telecom: Your Ticket to the Developer’s Playground

Let’s get straight to the point and turn you into a real Open API developer by breaking down the core concepts of how a Network API actually works.

First, let’s clarify what an Open API is and how it differs from a standard API.

"The main difference is that an Open API is publicly available, whereas a regular API might be restricted to specific users or partners" by Gemini

What this means is that as long as you keep your API publicly available—including documentation and specifications—you can call yourself an Open API developer.

For a Proof of Concept (PoC), this sounds like a lot of fun. But whenever a new trend or technology emerges, there’s always an opportunity to make it profitable.

In this lab, I will show you how to interact with Vonage Network API for FREE

Index

  1. Introduction
  2. Scope
  3. State of Art
  4. Implementation
  5. What is next?
  6. Final words

Scope:

I will show you how to interact with Vonage SMS API and Number Verification API, one of the insert complexity here use cases from Communication and Network API catalogue.

State of Art:

Vonage CPaaS (Communications Platform as a Service) is a cloud-based platform that provides various real-time communication features, including voice, messaging, and video. Instead of building a communication infrastructure from scratch—which requires significant time, resources, and maintenance—businesses can integrate specific communication functions into their applications with ease. Vonage handles most of the maintenance, allowing companies to focus on their core services while leveraging powerful communication capabilities.

CPaaS can include the following 2 categories:

Communication APIs:

  • Voice
  • SMS
  • Video
  • Authentication
  • IP Chat

Network APIs:

  • Silent Auth
  • QoD
  • Location
  • Device Data

Implementation

Pre-requisites

For this demo you only need:

  1. Valid phone number
  2. Vonage Free Account

Create Vonage Account

Create your account here: https://dashboard.nexmo.com/sign-up.

Create Account

Verify Your Account and Log In Securely

Verify your account

  1. Click "Verify Email Address"

    • After clicking, you will be redirected to a web page.
  2. Enter Your Phone Number

    • On the web page, you will see a phone number input screen.
    • Enter your phone number, and you will receive an SMS with a verification code.
  3. Enter the Verification Code

    • Input the received verification code on the web page to complete your account creation.
  4. Enable Extra Security (Optional)

    • If you select "Repeat this step whenever I log in from an unusual device or location," SMS verification will be required each time you log in from a new device or IP address.

Vonage API Dashboard

Once you are registered and authenticated, you will access to Vonage API dashboard that highlights all the capabilities you as a brand-new API developer can achieve. Let's take a quick look on the Dashboard details:

Vonage API Dashboard

Description:

  1. Vonage Credit: Did I say Vonage is free? It was true! BUT until certain point. Think about this like an AWS Free credits benefit for API Gateway, based of course on # of API calls. Once you created your account, you will be granted a $10 Credit* to start playing with existing APIs, create Applications that use Vonage API and even setup integration with other vendors e.g. AWS, Azure, OpenAI among others.

  2. API Key and API key: These are your unique ID to authenticate your account while testing Vonage APIs, so do not disclose to anyone unless you want to give away your free credit, or your whole wallet.

  3. Troubleshoot & Learn: As it name implies, this is the section we will dive deep in this lab as it includes the 2 APIs we are going to work with: "Send a SMS" and "Verify User"

Vonage SMS API

By utilizing SMS, you can reduce the volume of incoming calls.

Benefits:

Various System Integrations

  • 1 API call = 1 SMS sent → Easily integrates with other systems

Domestic Delivery Routes

  • Redundancy with multiple suppliers for domestic delivery routes
  • You can set your existing phone number as the Sender ID
  • To avoid delivery blocks, you can register the message with the supplier

Delivery Feedback (Delivery Receipt "DLR")

  • You can instantly check delivery results

Global Support

  • Compliance with regulations in each country and application support

Reporting

  • Usage and delivery reports, log search, and management screen available
  • Custom report development is possible
SMS API - GUI Implementation:

SMS API

SMS API call is quite straightforward, and your only concern will be how many characters you can use and if any special character is not allowed. Find below an example of a success SMS API call:

SMS API 200

SMS API - Code Implementation:

To implement this using your favorite programming language, please refer to the following code. There are quite a few options to choose, but I will use Python for sake of easiness:

Install the library

pip install vonage
Enter fullscreen mode Exit fullscreen mode

Initialize the library

client = vonage.Client(key="XXXXX", secret="YYYYYYY")
sms = vonage.Sms(client)
Enter fullscreen mode Exit fullscreen mode

Write the code

responseData = sms.send_message(
    {
        "from": "Vonage APIs",
        "to": "817014166666",
        "text": "Hello from https://dev.to/mgonzalezo",
    }
)

if responseData["messages"][0]["status"] == "0":
    print("Message sent successfully.")
else:
    print(f"Message failed with error: {responseData['messages'][0]['error-text']}")

Enter fullscreen mode Exit fullscreen mode

Vonage Number verification API

The Verify API allows you to send a PIN to a user's phone and confirm its receipt. It can be used for authentication and fraud prevention, including two-factor authentication, passwordless login, and phone number verification.

Number verification API - GUI implementation:

You start by selecting the PIN length and send the verification SMS:

Verify Number API

Notice there are 2 channels to notify the PIN Code, through SMS and up to 2 phone calls. This is possible due to the API design and specifications to include these alternatives

Verify Number API 2

After PIN code is entered and verification is successful, you will get a report of the credits consumed.

Verify Number API 3

Number verification API - Code Implementation:

Install the library

pip install vonage
Enter fullscreen mode Exit fullscreen mode

Initialize the Library

client = vonage.Client(key="xxxxx", secret="yyyy")
verify = vonage.Verify(client)
Enter fullscreen mode Exit fullscreen mode

Make a verification request

response = verify.start_verification(number="817014166666", brand="AcmeInc")

if response["status"] == "0":
    print("Started verification request_id is %s" % (response["request_id"]))
else:
    print("Error: %s" % response["error_text"])
Enter fullscreen mode Exit fullscreen mode

Check the request with a code

response = verify.check(REQUEST_ID, code=CODE)

if response["status"] == "0":
    print("Verification successful, event_id is %s" % (response["event_id"]))
else:
    print("Error: %s" % response["error_text"])
Enter fullscreen mode Exit fullscreen mode

Cancel The Request

response = verify.cancel(REQUEST_ID)

if response["status"] == "0":
    print("Cancellation successful")
else:
    print("Error: %s" % response["error_text"])
Enter fullscreen mode Exit fullscreen mode

What is next?

For you, eager developer, the next step is to review the documentation for each of these 2 APIs and start thinking new integrations or variations for your own use case!

SMS API:

Number Verification API:

Create your own API using AWS?

I don't want to re-invent the wheel, so please check this interesting blog entry by Raktim Midya about Rest API implementation:

https://medium.com/geekculture/provision-resources-in-aws-using-your-own-rest-api-cc54b390a71f

Final words

That's a wrap! I hope you enjoy implementing these use cases and exploring more about Open API technologies.

Happy Learning!

Top comments (0)