npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rajaongkir-node-js

v2.0.1

Published

rest client for rajaongkir API

Readme

rajaongkir-node-js

Github All Releases

Package ini dapat digunakan untuk membuat rest client pada web app anda dan sudah dicoba di framework express dan berjalan dengan baik.

instalasi

npm install rajaongkir-node-js

Penggunaan

Inisialisasi

const {init} = require('rajaongkir-node-js')
// masukan api-key tipe akun
const request = init('api-key', 'starter')

request object memiliki tiga method, get dan post

get(path)

post(postType, data,[headers])

postInternational(data,[headers])

Package ini mengikuti endpoint yang sama dengan dokumentasi di rajaongkir, akan tetapi path pertama bebas mengunakan nama apa saja.

Contoh Penggunaan di express js

Menggunakan promise

// server
//dependencies
const express = require('express')
const router = express.Router()
const {init} = require('rajaongkir-node-js')
const bodyParser = require('body-parser')
const urlencodedParser = bodyParser.urlencoded({extended: false})
const request = init('apiKey', 'starter')
//express
var app = express()
	app.use('/', router)

	router.post('/path/cost',urlencodedParser, function(req, res) {
	const {body,headers} = req
	// headers argument is optional
		const cost = request.post('cost',body,headers)
		cost.then(x => {
				res.write(x)
				res.end()
		}
	)
});

router.post('/path/waybill',urlencodedParser, function(req, res) {
const {body,headers} = req
// headers argument is optional
	const cost = request.post('waybill',body,headers)
	cost.then(x => {
			res.write(x)
			res.end()
	}
)
});

	router.get('/path/:query', function(req, res) {
		const{url} = req
		const regionType = request.get(url)
		regionType.then(x => {
				res.write(x)
				res.end()
		}
		)
	})

	router.get('/path/:region/:query', function(req, res) {
		const{url} = req
		const regionType = request.get(url)
		regionType.then(x => {
				res.write(x)
				res.end()
		}
		)
	})

		router.get('/form', function(req, res) {
			res.send(`
					<html>
						<head>
						<title> testing form </title>

						<script>
						const submit = () => {
						document.getElementById('form').submit()
						console.log('submit')
						}

						</script>
						</head>
						<body>
							<form id="form" action="path/cost" method="post">
								<input name="origin" type="number" placeholder="input id kota origin" /> <br/>
								<input name="originType" type="text" placeholder="tipe kota origin" /> <br/>
								<input name="destination" type="number" placeholder="input id kota tujuan" /> <br/>
								<input name="destinationType" type="text" placeholder="tipe kota tujuan" /> <br/>
								<input name="weight" type="integer" placeholder="masukan berat (gr)" /> <br/>
								<input name="courier" type="text" placeholder="periksa ongkir" /> <br/>
								<input type="submit" onclick="submit()"> Submit </input>
							</form>
						</body>
					</html>
				`)
			res.end()
		})

// node server
var server = app.listen(8080, function() {
	console.log("server berjalan di http://localhost:8080")
})

Contoh penggunaan diluar server, tidak disarankan karena api key akan terekspose.

const {init} = require('rajaongkir-node-js')
const request = init('apiKey', 'starter')

// get
const province = request.get('/province')
province.then(prov => {
	console.log(prov);
})
// menggunakan query
const allCityInProvince = request.get('/city?&province=1')
allCityInProvince.then(city => console.log(city))

const specificCityInProvince = request.get('/city?id=39&province=5')

const currency = request('/currency') // path currency hanya tersedia di akun pro
province.then(curr => {
	console.log(curr);
})

const international = request.get('v2/internationalDestination?id=108') // akun pro
														 .then(nation => console.log(nation))


// post
const data = {
  origin: 501,
  destination: 114,
  weight: 1700,
  courier: 'jne:pos' // bisa merequest satu atau beberapa kurir sekaligus
}
const cost = request.post('cost',data)
cost.then(cst => {
	console.log(cst);
})

const dataResi = { waybill: 'SOCAG00183235715', courier: 'jne' }
const resi = request.post('waybill',dataResi)
resi.then(wb => {
	console.log(wb);
})

const intData = {
	origin: '152',
  destination: '108',
  weight: 1400,
  courier: 'pos'
}
//post international
postInternational(data,[headers]) // hanya tersedia di akun pro
const internationalCost = request.postInternational(intData)
internationalCost.then(cost => console.log(cost);)