You are on page 1of 5

Binary Data Formats

and Web APIs


Byte Order Size and Alignment of Environment

To get byte order


>>>import sys
>>>sys.byteorder()

Character Byte order Size Alignment


@ native native native
= native standard none
< little-endian standard none
> big-endian standard none
! network (= big-endian) standard none
Types of Binary Data Formats
Format Python type Standard size
c string of length 1 1
b integer 1
B integer 1
? bool 1
h integer 2
H integer 2
i integer 4
I integer 4
l integer 4
L integer 4
q integer 8
Q integer 8
f float 4
d float 8
Packing and Unpacking of Data
>>>import struct as st

>>>st.pack(‘byteorderFormat’, data) #Packing of Data

>>>st.unpack(‘byteorderFormat’,data(in binary format))#Unpacking of


data
What are APIs

• API means Application Programming Interface

• APIs use HTTP protocol to interact with web services

• Python converts APIs data into JSON (Java Script Object Notation)
format

• APIs help programs to interact directly with web services

• Check Quandl site for API interaction

You might also like