Skip to content

slaveofcode/rajaongkir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status GitHub license

rajaongkir

Simple Python module to grab api data from rajaongkir.com (http://rajaongkir.com/dokumentasi/starter), you can use it by Django, Flask or any framework you used.

If you have no ApiKey to use, you can create one here: http://rajaongkir.com/akun/daftar

Install

# Directly install from last stable release

pip install git+ssh://[email protected]/slaveofcode/[email protected]

# Or with official pypi

pip install rajaongkir

How to Use ?

from rajaongkir import RajaOngkirApi

# initialization
api = RajaOngkirApi(api_key='YourRajaOngkirApiKeyHere')

# get province list
list_of_city = api.provinces()
# returned values will be a list of provinces [{'province': 'Jawa Barat', ...}]

# get city list
list_of_city = api.cities()
# returned values will be a list of cities [{'city_name': 'Bekasi', city_id: 55, ...}]

# get cities based on province_id 
list_of_city = api.cities_by_province(9)
# [{'city_name': 'Bekasi', 'city_id': 55, 'type': 'Kota', ...}, {'city_name': 'Bandung', 'city_id': 23, 'type': 'Kota', ...}]
 
# get city by id
city = api.city_by_id(55)
# {'city_name': 'Bekasi', city_id: 55, ...}

# get the cost (55 is Bekasi, 23 is Bandung, 1000 grams = 1 kg, 'all' = all courier
# available courier is 'all', 'jne', 'tiki' and 'pos'
cost = api.cost_between_city(55, 23, 1000, 'all')

Run The Test

I'm using unittest to test the whole functionality of RajaOngkirApi class, you can run it by using console or set your test in pycharm using Unittest configuration

Please take a note you must set your API_KEY inside of rajaongkirapi_tests.py to make sure the api works

Here's some sample while you runs the test over the console or terminal

>> python test/unit/rajaongkirapi_test.py

>> Ran 7 tests in 4.322s

>> OK

Other choice you can run the test by using nosetests, make sure nosetest already installed, or you can run command pip install nose to install them

>> nosetests

>> ----------------------------------------------------------------------

>> Ran 7 tests in 4.899s

>> OK

About

Simple Python module to grab api data from rajaongkir.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages