오너클랜 API 센터
로그인 | 회원가입

사용법

API Endpoint

오너클랜 API는 Production과 Sandbox 환경 모두에 엔드포인트를 제공합니다.
해당 엔드포인트를 통해 GraphQL 쿼리를 사용할 수 있습니다.

API URL

  • Production: https://api.ownerclan.com/v1/graphql
  • Sandbox: https://api-sandbox.ownerclan.com/v1/graphql

GraphQL Playground URL

  • Production: https://api.ownerclan.com/v1/graphql
  • Sandbox: https://api-sandbox.ownerclan.com/v1/graphql

각 환경의 엔드포인트에 접속하여 GraphQL Playground에서 직접 쿼리를 실행하고 테스트할 수 있습니다.

JWT 인증

오너클랜 API는 JWT 토큰 인증 방식을 사용합니다.
인증을 위해서는 해당 엔드포인트로 아이디와 비밀번호를 POST 요청하여 JWT 토큰을 발급받아야 합니다.

Authentication Endpoint

  • Production: https://auth.ownerclan.com/auth
  • Sandbox: https://auth-sandbox.ownerclan.com/auth

인증 방식

인증 방식은 JWT를 기반으로 하며, 다음과 같은 데이터를 포함한 POST 요청을 통해 토큰을 발급받을 수 있습니다.

                var authData = {
                    service: "ownerclan",
                    userType: "seller",
                    username: "판매사ID",
                    password: "판매사PW"
                };
        
                $.ajax({
                    url: "https://auth-sandbox.ownerclan.com/auth",
                    type: "POST",
                    contentType: "application/json",
                    processData: false,
                    data: JSON.stringify(authData),
                    success: function(data) {
                        console.log(data); // 발급된 토큰을 콘솔에 출력합니다.
                    },
                    error: function(data) {
                        console.error(data.responseText, data.status); // 에러 처리
                    }
                });
                

GraphQL 사용법

GraphQL은 단일 엔드포인트에서 모든 데이터를 쿼리하거나 수정할 수 있습니다.
오너클랜 API는 GraphQL로 구현되어 있으며, 해당 엔드포인트를 통해 데이터를 요청할 수 있습니다.

예시 쿼리

        query {
            item(key: "W000000") {
                name
                model
                options {
                    price
                    quantity
                    optionAttributes {
                        name
                        value
                    }
                }
            }
        }
                

예시 응답

        {
            "data": {
                "item": {
                    "name": "예시 상품",
                    "model": "예시 모델",
                    "options": [
                        {
                            "price": 35000,
                            "quantity": 23,
                            "optionAttributes": [
                                { "name": "색상", "value": "RED" },
                                { "name": "사이즈", "value": "95" }
                            ]
                        }
                    ]
                }
            }
        }
                

쿼리 전송 방식

GET 또는 POST 요청을 사용해 GraphQL 쿼리를 전송할 수 있습니다. 예시는 다음과 같습니다:

        var client = new XMLHttpRequest();
        var readQuery = `query { item(key: "W000000") { name, model } }`;
        client.open("GET", "https://api-sandbox.ownerclan.com/v1/graphql?query=" + encodeURIComponent(readQuery), true);
        client.setRequestHeader("Authorization", "Bearer YOUR_TOKEN");
        client.send(null);