curl --request POST \
  --url http://pro.rajaongkir.com/api/cost \
  --header 'content-type: application/x-www-form-urlencoded' \
  --header 'key: your-api-key' \
  --data 'origin=501&originType=city&destination=574&destinationType=subdistrict&weight=1700&courier=jne'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://pro.rajaongkir.com/api/cost",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "origin=501&originType=city&destination=574&destinationType=subdistrict&weight=1700&courier=jne",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/x-www-form-urlencoded",
    "key: your-api-key"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
require 'uri'
require 'net/http'

url = URI("http://pro.rajaongkir.com/api/cost")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["key"] = 'your-api-key'
request["content-type"] = 'application/x-www-form-urlencoded'
request.body = "origin=501&originType=city&destination=574&destinationType=subdistrict&weight=1700&courier=jne"

response = http.request(request)
puts response.read_body
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"key": @"your-api-key",
                           @"content-type": @"application/x-www-form-urlencoded" };

NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"origin=501" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&originType=city" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&destination=574" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&destinationType=subdistrict" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&weight=1700" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&courier=jne" dataUsingEncoding:NSUTF8StringEncoding]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://pro.rajaongkir.com/api/cost"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];
import Foundation

let headers = [
  "key": "your-api-key",
  "content-type": "application/x-www-form-urlencoded"
]

var postData = NSMutableData(data: "origin=501".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&originType=city".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&destination=574".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&destinationType=subdistrict".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&weight=1700".dataUsingEncoding(NSUTF8StringEncoding)!)
postData.appendData("&courier=jne".dataUsingEncoding(NSUTF8StringEncoding)!)

var request = NSMutableURLRequest(URL: NSURL(string: "http://pro.rajaongkir.com/api/cost")!,
                                        cachePolicy: .UseProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.allHTTPHeaderFields = headers
request.HTTPBody = postData

let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    println(error)
  } else {
    let httpResponse = response as? NSHTTPURLResponse
    println(httpResponse)
  }
})

dataTask.resume()
import http.client

conn = http.client.HTTPConnection("pro.rajaongkir.com")

payload = "origin=501&originType=city&destination=574&destinationType=subdistrict&weight=1700&courier=jne"

headers = {
    'key': "your-api-key",
    'content-type': "application/x-www-form-urlencoded"
    }

conn.request("POST", "/api/cost", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://pro.rajaongkir.com/api/cost"

	payload := strings.NewReader("origin=501&originType=city&destination=574&destinationType=subdistrict&weight=1700&courier=jne")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("key", "your-api-key")
	req.Header.Add("content-type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
var qs = require("querystring");
var http = require("http");

var options = {
  "method": "POST",
  "hostname": "pro.rajaongkir.com",
  "port": null,
  "path": "/api/cost",
  "headers": {
    "key": "your-api-key",
    "content-type": "application/x-www-form-urlencoded"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(qs.stringify({ origin: '501',
  originType: 'city',
  destination: '574',
  destinationType: 'subdistrict',
  weight: 1700,
  courier: 'jne' }));
req.end();
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "origin=501&originType=city&destination=574&destinationType=subdistrict&weight=1700&courier=jne");
Request request = new Request.Builder()
  .url("http://pro.rajaongkir.com/api/cost")
  .post(body)
  .addHeader("key", "your-api-key")
  .addHeader("content-type", "application/x-www-form-urlencoded")
  .build();

Response response = client.newCall(request).execute();