API 연동 샘플 코드

언어별 Rentmaster API 연동 기본 예제 코드입니다.

[필수] API 허용 IP 등록 안내
Rentmaster API는 보안상 상점 관리자에 등록된 서버 IP에서만 호출할 수 있습니다.
브라우저(프론트엔드)에서 직접 호출할 수 없으므로, 반드시 백엔드 서버(PHP, Java 등)를 경유해 호출해 주세요.
PHP
ASP
Java
React
상품목록조회
상품상세
예약 (POST)
마이페이지 내역
예약취소 (POST)

[PHP] 상품목록조회 API

<?php
$api_url = "https://rentmaster.co.kr/api/v1/item/list";
$api_key = "발급받은_API_KEY";
$page = 1;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url . "?page=" . $page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . $api_key,
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if ($result && $result['success']) {
    foreach ($result['data'] as $item) {
        echo "상품명: " . $item['itemname'] . "<br>";
        echo "대여가능: " . $item['available_stock'] . "<hr>";
    }
} else {
    echo "데이터를 불러오는데 실패했습니다.";
}
?>

[PHP] 상품상세 API

<?php
$itemcode = "상품코드입력";
$api_url = "https://rentmaster.co.kr/api/v1/item/detail?itemcode=" . $itemcode;
$api_key = "발급받은_API_KEY";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . $api_key
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if ($result && $result['success']) {
    $data = $result['data'];
    echo "<h1>" . $data['itemname'] . "</h1>";
    echo "<p>예약가능 재고: " . count($data['barcodes']) . "</p>";
}
?>

[PHP] 예약 처리 API

<?php
$api_url = "https://rentmaster.co.kr/api/v1/rent/reserve";
$api_key = "발급받은_API_KEY";

$post_data = json_encode([
    'barcode' => '예약할_바코드',
    'member_no' => '회원_고유번호',
    'target_date' => '2023-12-31',
    'reserve_type' => 'delivery',
    'dlv_zipcode' => '12345',
    'dlv_addr1' => '서울시 강남구',
    'dlv_addr2' => '101동 101호'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . $api_key,
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if ($result && $result['success']) {
    echo "예약 성공!";
} else {
    echo "예약 실패: " . $result['error'];
}
?>

[PHP] 마이페이지 내역 API

<?php
$member_no = "회원_고유번호";
$api_url = "https://rentmaster.co.kr/api/v1/rent/my_list?ext_id=" . $member_no;
$api_key = "발급받은_API_KEY";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . $api_key
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if ($result && $result['success']) {
    foreach ($result['data'] as $rent) {
        echo "상태: " . $rent['status_name'] . " / 상품명: " . $rent['itemname'] . "<br>";
    }
}
?>

[PHP] 예약취소 API

<?php
$api_url = "https://rentmaster.co.kr/api/v1/rent/cancel_reserve";
$api_key = "발급받은_API_KEY";

$post_data = json_encode([
    'orderno' => '예약_고유번호',
    'ext_id' => '회원_고유번호'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . $api_key,
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if ($result && $result['success']) {
    echo "취소 완료!";
} else {
    echo "취소 실패: " . $result['error'];
}
?>

[ASP] 상품목록조회 API

<%
Dim api_url, api_key, xmlHttp, responseText
api_url = "https://rentmaster.co.kr/api/v1/item/list?page=1"
api_key = "발급받은_API_KEY"

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", api_url, False
xmlHttp.setRequestHeader "Authorization", "Bearer " & api_key
xmlHttp.setRequestHeader "Content-Type", "application/json"
xmlHttp.Send

responseText = xmlHttp.responseText
' JSON 파서를 활용하여 responseText를 파싱 후 사용하세요.
Response.Write responseText

Set xmlHttp = Nothing
%>

[ASP] 상품상세 API

<%
Dim itemcode, api_url, api_key, xmlHttp, responseText
itemcode = "상품코드입력"
api_url = "https://rentmaster.co.kr/api/v1/item/detail?itemcode=" & itemcode
api_key = "발급받은_API_KEY"

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", api_url, False
xmlHttp.setRequestHeader "Authorization", "Bearer " & api_key
xmlHttp.Send

responseText = xmlHttp.responseText
Response.Write responseText

Set xmlHttp = Nothing
%>

[ASP] 예약 처리 API

<%
Dim api_url, api_key, postData, xmlHttp, responseText
api_url = "https://rentmaster.co.kr/api/v1/rent/reserve"
api_key = "발급받은_API_KEY"

' JSON 형태로 데이터 구성
postData = "{""barcode"":""바코드"",""member_no"":""회원번호"",""target_date"":""2023-12-31"",""reserve_type"":""place"",""place_id"":1}"

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "POST", api_url, False
xmlHttp.setRequestHeader "Authorization", "Bearer " & api_key
xmlHttp.setRequestHeader "Content-Type", "application/json"
xmlHttp.Send postData

responseText = xmlHttp.responseText
Response.Write responseText

Set xmlHttp = Nothing
%>

[ASP] 마이페이지 내역 API

<%
Dim member_no, api_url, api_key, xmlHttp, responseText
member_no = "회원번호"
api_url = "https://rentmaster.co.kr/api/v1/rent/my_list?ext_id=" & member_no
api_key = "발급받은_API_KEY"

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", api_url, False
xmlHttp.setRequestHeader "Authorization", "Bearer " & api_key
xmlHttp.Send

responseText = xmlHttp.responseText
Response.Write responseText

Set xmlHttp = Nothing
%>

[ASP] 예약취소 API

<%
Dim api_url, api_key, postData, xmlHttp, responseText
api_url = "https://rentmaster.co.kr/api/v1/rent/cancel_reserve"
api_key = "발급받은_API_KEY"

postData = "{""orderno"":""주문번호"",""ext_id"":""회원번호""}"

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "POST", api_url, False
xmlHttp.setRequestHeader "Authorization", "Bearer " & api_key
xmlHttp.setRequestHeader "Content-Type", "application/json"
xmlHttp.Send postData

responseText = xmlHttp.responseText
Response.Write responseText

Set xmlHttp = Nothing
%>

[Java] 상품목록조회 API

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RentmasterApi {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://rentmaster.co.kr/api/v1/item/list?page=1");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Authorization", "Bearer 발급받은_API_KEY");
            conn.setRequestProperty("Content-Type", "application/json");

            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            StringBuilder response = new StringBuilder();
            while ((line = br.readLine()) != null) {
                response.append(line);
            }
            br.close();
            
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

[Java] 상품상세 API

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RentmasterDetailApi {
    public static void main(String[] args) {
        try {
            String itemcode = "상품코드입력";
            URL url = new URL("https://rentmaster.co.kr/api/v1/item/detail?itemcode=" + itemcode);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Authorization", "Bearer 발급받은_API_KEY");

            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            StringBuilder response = new StringBuilder();
            while ((line = br.readLine()) != null) {
                response.append(line);
            }
            br.close();
            
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

[Java] 예약 처리 API

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RentmasterReserveApi {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://rentmaster.co.kr/api/v1/rent/reserve");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Authorization", "Bearer 발급받은_API_KEY");
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setDoOutput(true);

            String jsonInputString = "{\"barcode\":\"바코드\",\"member_no\":\"회원번호\",\"target_date\":\"2023-12-31\",\"reserve_type\":\"delivery\",\"dlv_zipcode\":\"12345\",\"dlv_addr1\":\"서울시 강남구\",\"dlv_addr2\":\"101동 101호\"}";
            
            try(OutputStream os = conn.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);			
            }

            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            StringBuilder response = new StringBuilder();
            while ((line = br.readLine()) != null) {
                response.append(line);
            }
            br.close();
            
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

[Java] 마이페이지 내역 API

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RentmasterMyPageApi {
    public static void main(String[] args) {
        try {
            String extId = "회원번호";
            URL url = new URL("https://rentmaster.co.kr/api/v1/rent/my_list?ext_id=" + extId);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Authorization", "Bearer 발급받은_API_KEY");

            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            StringBuilder response = new StringBuilder();
            while ((line = br.readLine()) != null) {
                response.append(line);
            }
            br.close();
            
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

[Java] 예약취소 API

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RentmasterCancelApi {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://rentmaster.co.kr/api/v1/rent/cancel_reserve");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Authorization", "Bearer 발급받은_API_KEY");
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setDoOutput(true);

            String jsonInputString = "{\"orderno\":\"주문번호\",\"ext_id\":\"회원번호\"}";
            
            try(OutputStream os = conn.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);			
            }

            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            StringBuilder response = new StringBuilder();
            while ((line = br.readLine()) != null) {
                response.append(line);
            }
            br.close();
            
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

[React] 상품목록조회 API

import React, { useState, useEffect } from 'react';

// 프론트엔드에서는 브라우저 보안 및 IP 차단 문제를 피하기 위해
// 직접 Rentmaster API를 호출하지 않고, 내부 백엔드 서버(Proxy)를 호출합니다.

function ProductList() {
  const [items, setItems] = useState([]);

  useEffect(() => {
    // 내부 백엔드 API (예: Node.js, Spring, PHP 등에서 작성한 프록시 엔드포인트)
    fetch("/api/backend_proxy?endpoint=/item/list&page=1")
    .then(res => res.json())
    .then(data => {
      if (data.success) {
        setItems(data.data);
      }
    });
  }, []);

  return (
    <div>
      {items.map(item => (
        <div key={item.itemcode}>
          <h4>{item.itemname}</h4>
          <p>재고: {item.available_stock}</p>
        </div>
      ))}
    </div>
  );
}
export default ProductList;

[React] 상품상세 API

import React, { useState, useEffect } from 'react';

function ProductDetail({ itemcode }) {
  const [item, setItem] = useState(null);

  useEffect(() => {
    fetch(`/api/backend_proxy?endpoint=/item/detail&itemcode=${itemcode}`)
    .then(res => res.json())
    .then(data => {
      if (data.success) setItem(data.data);
    });
  }, [itemcode]);

  if (!item) return <div>Loading...</div>;

  return (
    <div>
      <h1>{item.itemname}</h1>
      <p>보유 바코드 수: {item.barcodes?.length}</p>
    </div>
  );
}
export default ProductDetail;

[React] 예약 처리 API

import React from 'react';

function ReserveForm() {
  const handleReserve = async () => {
    const payload = {
      barcode: "바코드",
      member_no: "회원번호",
      target_date: "2023-12-31",
      reserve_type: "delivery",
      dlv_zipcode: "12345",
      dlv_addr1: "서울시 강남구",
      dlv_addr2: "101동 101호"
    };

    const res = await fetch("/api/backend_proxy?endpoint=/rent/reserve", {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify(payload)
    });
    
    const data = await res.json();
    if (data.success) {
      alert("예약이 완료되었습니다.");
    } else {
      alert(`예약 실패: ${data.error}`);
    }
  };

  return (
    <button onClick={handleReserve}>예약하기</button>
  );
}
export default ReserveForm;

[React] 마이페이지 내역 API

import React, { useState, useEffect } from 'react';

function MyPage({ memberNo }) {
  const [list, setList] = useState([]);

  useEffect(() => {
    fetch(`/api/backend_proxy?endpoint=/rent/my_list&ext_id=${memberNo}`)
    .then(res => res.json())
    .then(data => {
      if (data.success) setList(data.data);
    });
  }, [memberNo]);

  return (
    <ul>
      {list.map(rent => (
        <li key={rent.orderno}>
          {rent.itemname} - {rent.status_name}
        </li>
      ))}
    </ul>
  );
}
export default MyPage;

[React] 예약취소 API

import React from 'react';

function CancelButton({ orderno, memberNo }) {
  const handleCancel = async () => {
    if (!window.confirm("예약을 취소하시겠습니까?")) return;

    const res = await fetch("/api/backend_proxy?endpoint=/rent/cancel_reserve", {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ orderno: orderno, ext_id: memberNo })
    });
    
    const data = await res.json();
    if (data.success) {
      alert("예약이 취소되었습니다.");
    } else {
      alert(`취소 실패: ${data.error}`);
    }
  };

  return (
    <button onClick={handleCancel}>예약 취소</button>
  );
}
export default CancelButton;
✨ AI 맞춤 물품 큐레이터
내 상점 · 실시간 재고 기반 추천
안녕하세요! AI 대여 큐레이터입니다.
아이 연령이나 찾으시는 장난감·도서 특징, 예약 방법을 물어보시면 현재 대여 가능한 추천 품목을 즉시 안내해 드립니다.

Rentmaster API Test Portal
Powered by Etopia Co., Ltd.