Programming Bootcamp
Agenda
- What is an API
- Intro to Python
- What is an SDK
- Catapult Capabilities
What is an API?
And why do they matter
API
A: application P: programming I: interface
Break it down
Application - Tools/games/social networks
Programming - How engineers create software
Interface - common boundary shared by two applications or programs that allow both to communicate with one another.
So an API is essentially a way for programmers to communicate with a certain application.

Why do APIs Matter
- Faster development
- Higher Abstraction
- Replaceable
http GET
Ask for information
- View Facebook.com
- Search google.com
- Visit a webpage
- Other...
http POST
Give information
- Upload photo to facebook
- Send an email
- Post a tweet
- Other...
Python
An Introduction
Play Around
# Say Hello World
print('Hello World')
# Do some math
1337 - 345
# Debug
print('Hello' + 'World')
# Variables
a = 1 + 1
print(a)
# More Variables
a = a + 3
print(a)
# Debug
print('a = ' + a)
# Array
numbers = [1, 2, 3, 4, 5, 6, 7]
print(numbers)
# Loops
for number in numbers:
print(number)
Requests
import requests
r = requests.get('https://api.github.com/events')
print(r.text)$ pip install requests
$ python sample_requests.py
import requests
r = requests.get('https://api.catapult.inetwork.com/v1/availableNumbers/local?areaCode=919',
auth=('{your_token}', '{your_secret'))
print(r.text)$ python sample_requests.py
Now let's order a number
import requests
r = requests.get('https://api.catapult.inetwork.com/v1/availableNumbers/local?areaCode=919',
auth=('{your_token}', '{your_secret'))
print(r.text)$ python sample_requests.py
import requests
r = requests.get('https://api.catapult.inetwork.com/v1/availableNumbers/local?areaCode=919',
auth=('{your_token}', '{your_secret'))
print(r.text)
url = 'https://api.catapult.inetwork.com/v1/users/u-chpha5epa2nb4euazc5wlgi/phoneNumbers'
payload = '{"number": "+19192961449"}'
headers = {"Content-Type": "application/json"}
r = requests.post(
url,
auth=('{your_token}', '{your_secret'),
data=payload,
headers=headers)
print(r)SDKs
And why they exist
SDK
S: software D: development K: kit
Break it down
SDKs allow programmers to quickly program without writing common code.
"All SDKs are/contain APIs but not all APIs are SDKs".
Real World Example
from bandwidth_sdk import Client
from bandwidth_sdk import PhoneNumber
Client('{your_user_id}', '{your_token}', '{your_secret}')
available_numbers = PhoneNumber.list_local(area_code = '919')
print(available_numbers)
number = available_numbers[0].allocate()
print(number)
print(number.number)
Message yourself!
from bandwidth_sdk import Client
from bandwidth_sdk import PhoneNumber
from bandwidth_sdk import Message
Client('{your_user_id}', '{your_token}', '{your_secret}')
available_numbers = PhoneNumber.list_local(area_code = '919')
print(available_numbers)
number = available_numbers[0].allocate()
print(number)
print(number.number)
Message.send(
sender=number.number,
receiver='+19197891146',
text='test'
)Call yourself!
from bandwidth_sdk import Client
from bandwidth_sdk import PhoneNumber
from bandwidth_sdk import Message
from bandwidth_sdk import Call
from time import sleep
Client('{your_user_id}', '{your_token}', '{your_secret}')
available_numbers = PhoneNumber.list_local(area_code = '919')
print(available_numbers)
number = available_numbers[0].allocate()
print(number)
print(number.number)
Message.send(
sender=number.number,
receiver='+19197891146',
text='test'
)
call = Call.create(number.number, "+19197891146")
sleep(10)
call.speak_sentence("Hello from Bandwidth", gender="female")
call.hangup()Catapult
What can it do!?!?!?!?!?!?
Questions?
Programming Bootcamp
By Daniel Tolbert
Programming Bootcamp
- 701
