Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slaveofcode/rajaongkir
Simple Python module to grab api data from rajaongkir.com
https://github.com/slaveofcode/rajaongkir
Last synced: about 8 hours ago
JSON representation
Simple Python module to grab api data from rajaongkir.com
- Host: GitHub
- URL: https://github.com/slaveofcode/rajaongkir
- Owner: slaveofcode
- License: mit
- Created: 2015-09-19T04:08:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T21:33:46.000Z (over 1 year ago)
- Last Synced: 2024-11-06T19:54:53.319Z (13 days ago)
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 6
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/slaveofcode/rajaongkir.svg?branch=master)](https://travis-ci.org/slaveofcode/rajaongkir) [![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/slaveofcode/rajaongkir/blob/master/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](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 worksHere'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