Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titlewindow(batch)

github

Code Block
chcp 65001 
:: Text Encoding to UTF-8 in CMD
:: Example For Get Lake List API by using curl in window script
:: written by yeony kim

set API_KEY=YOUR_API_TOKENKEY

set CONTENT_HEADER="Content-Type: application/json"
set API_HEADER="x-api-key: %API_KEY%"

set URL="https://api.machlake.com/v1/lakes"

:: ------------------------------------------------------------------------------------------------- ::

:: CASE - GET LAKE List

curl -k -X GET %URL% -H %CONTENT_HEADER% -H %API_HEADER%

:: Return Format
:: {"data":{"lake":[{
::     "success" : true,
::     "reason"  : "get list success",
::     "data": [
::         {
::             "lake_id" : "YOUR_LAKE_ID",{lake_id}",
::             "lake_info" : {
::                 "lake_name"    : "sample_lake",
::                 "lake_plan"    : "basic",
::                 "region"       :"ap-northeast-2","timezone": "aws1.kor",
::                 "timezone"     : "Asia/Seoul"
::             }}],"mount":[],"share":[]},"status":"success"}
::         },
::         ......
::     ]
:: }
Expand
titlelinux(shell)

github

Code Block
# Text Encoding to UTF-8 in CMD
# Example For Get Lake List API by using curl in shell script
# written by yeony kim

API_KEY=YOUR$YOUR_API_TOKENKEY

CONTENT_HEADER="Content-Type:application/json"
API_HEADER="x-api-key:$API_KEY"

URL=https://api.machlake.com/v1/lakes

# ------------------------------------------------------------------------------------------------- #

# CASE - GET LAKE List

curl -k -X GET $URL -H $CONTENT_HEADER -H $API_HEADER

# Return Format
# {"data":{"lake":[{
#     "success" : true,
#     "reason"  : "get list success",
#     "data": [
#         {
#             "lake_id" : "YOUR_LAKE_ID",{lake_id}",
#             "lake_info" : {
#                 "lake_name"    : "sample_lake",
#                 "lake_plan"    : "basic",
#                 "region"       :"ap-northeast-2","timezone": "aws1.kor",
#                 "timezone"     : "Asia/Seoul"
#             }}],"mount":[],"share":[]},"status":"success"
#         },
#         ......
#     ]
# }
Expand
titlejavascript

github

Code Block
languagejs
// Example For Get Lake List API by using request in nodejs
// written by yeony kim

// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

const express = require('express');
const app
=
express();
const API_KEY = "YOUR_API_TOKEN";
const URL = "https://api.machlake.com/v1/lakes";

var request = require('request');

/* ------------------------------------------------------------------------------------------------- */

// CASE - GET LAKE List

apprequest.get({
    '/get_lake_list', function(req, res)url: URL, 
    headers: {
        var request = require('request');
  "Content-Type": "application/json",
        "x-api-key": API_KEY
    }}, 
    var option =function(error, response, body) {
        console.log(body);
   url: URL,    // Return Format
      headers: { // {
        //      'Content-Type': 'application/json'"success" : true,
        //     "reason"   'x-api-key': API_KEY: "get list success",
        //    }, "data": [
      };  //       request.get( option, function(error, response, body) { {
        //       if (!error) {    "lake_id" : "{lake_id}",
        //  res.writeHead(200);           "lake_info" : {
   res.end(body);     //               console.log(body) // {"data":{"lake":[{"lake_id":"YOUR_LAKE_ID","lake_info":{"lake_name":name"    : "sample_lake",
        //                 "lake_plan"    : "basic",
        //                 "region"       :"ap-northeast-2","timezone":"Asia/Seoul"}}],"mount":[],"share":[]},"status":"success"} "aws1.kor",
        //                 "timezone"     : "Asia/Seoul"
        //             }
else   {     //         },
  console.log(error)      //       }  ......
      })  //    } )]
 app.listen(8888, function() {     console.log('http://127.0.0.1:8888/get_lake_list is result for get LAKE list') }
    })
Expand
titlepython

github

Code Block
languagepy
"""
Example For Get Lake List API by using request in python
written by yeony kim
"""

import requests

API_KEY = "YOUR_API_TOKEN"
URL = f"https://api.machlake.com/v1/lakes"

#
CASE
- GET LAKE List

headers = {
    '"Content-Type'": '"application/json'",
    '"x-api-key'": API_KEY
}


# ------------------------------------------------------------------------------------------------- #

# CASE - GET LAKE List

response = requests.get(URL, headers=headers, verify=False)
print(response.content.decode('"utf-8'"))

# Return Format
# {"data":{"lake":[{
#     "success" : true,
#     "reason"  : "get list success",
#     "data": [
#         {
#             "lake_id" : "YOUR_LAKE_ID",{lake_id}",
#             "lake_info" : {
#                 "lake_name"    : "sample_lake",
#                 "lake_plan"    : "basic",
#                 "region"       :"ap-northeast-2","timezone": "aws1.kor",
#                 "timezone"     : "Asia/Seoul"
#             }}],"mount":[],"share":[]},"status":"success"}
#         },
#         ......
#     ]
# }