0

PyJNE is a tool to simplify the user in using the API JNE such as tracking stuff, check tariffs and others. This repository from kangfend is usefull if you use API JNE for your project.

Makesure you ask permission first to the JNE Company before use its API.

There you can see what destinations that will you tracking with price from JNE.

Such as what freature was added:

  • Get origin city code
  • Get destination city code
  • Check JNE tariffs
  • Tracking stuff
  • Find Nearby

And this simply how to get origin city code:

>>> from jne import Jne
>>> jne = Jne(api_key='d4dedbecf40d6d09f22704342c0', username='MYUSERNAME')
>>> jne.get_from_code('jakarta')
{u'detail': [{u'code': u'CGK10000', u'label': u'JAKARTA'}]}
>>>
>>> # Show result with pretty print
>>> jne.get_from_code('jakarta', pretty_print=True)   
{                                                     
  "detail": [                                         
    {                                                 
      "code": "CGK10000",                             
      "label": "JAKARTA"                              
    }                                                 
  ]                                                   
}                                                     
>>>

And this simply how to check price with jne api:

>>> jne.check_tariff(city_from='CGK10000', city_to='CBN10000', weight=1)
{u'price': [{u'service_code': u'OKE13', u'etd_from': u'2', u'price': u'9000', u'origin_name': u'JAKARTA', u'times': u'D', u'service_display': u'OKE', u'etd_thru': u'3', u'destination_name': u'CIREBON'}, {u'service_code': u'REG13', u'etd_from': u'1', u'price': u'10000', u'origin_name': u'JAKARTA', u'times': u'D', u'service_display': u'REG', u'etd_thru': u'2', u'destination_name': u'CIREBON'}, {u'service_code': u'SPS13', u'etd_from': None, u'price': u'350000', u'origin_name': u'JAKARTA', u'times': None, u'service_display': u'SPS', u'etd_thru': None, u'destination_name': u'CIREBON'}, {u'service_code': u'YES13', u'etd_from': u'1', u'price': u'19000', u'origin_name': u'JAKARTA', u'times': u'D', u'service_display': u'YES', u'etd_thru': None, u'destination_name': u'CIREBON'}]}
>>>
>>>
>>> # Show result with pretty print
>>> jne.check_tariff(city_from='CGK10000', city_to='CBN10000', weight=1, pretty_print=True)
{
  "price": [
    {
      "destination_name": "CIREBON",
      "etd_from": "2",
      "etd_thru": "3",
      "origin_name": "JAKARTA",
      "price": "9000",
      "service_code": "OKE13",
      "service_display": "OKE",
      "times": "D"
    },
    {
      "destination_name": "CIREBON",
      "etd_from": "1",
      "etd_thru": "2",
      "origin_name": "JAKARTA",
      "price": "10000",
      "service_code": "REG13",
      "service_display": "REG",
      "times": "D"
    },
    {
      "destination_name": "CIREBON",
      "etd_from": null,
      "etd_thru": null,
      "origin_name": "JAKARTA",
      "price": "350000",
      "service_code": "SPS13",
      "service_display": "SPS",
      "times": null
    },
    {
      "destination_name": "CIREBON",
      "etd_from": "1",
      "etd_thru": null,
      "origin_name": "JAKARTA",
      "price": "19000",
      "service_code": "YES13",
      "service_display": "YES",
      "times": "D"
    }
  ]
}
>>> 

For more information you can checkout on this repository https://github.com/kangfend/py-jne
Helpfull can help.

python django

Your Answer

blog comments powered by Disqus