Skip to content

04.03 Development Environment ​


📌 At a Glance ​

รายการรายละเอียด
TopicDevelopment Environment
Difficulty⭐ Beginner
Reading Time6 นาที
TargetDeveloper

🎯 Learning Objectives ​

หลังจากศึกษาหัวข้อนี้แล้ว ผู้อ่านจะสามารถ

  • เตรียม Development Environment สำหรับเชื่อมต่อ SISAHYGO API
  • จัดเก็บ Configuration อย่างปลอดภัย
  • ทดสอบการเชื่อมต่อกับ Production API ได้

Overview ​

การเตรียม Development Environment ที่เหมาะสม จะช่วยลดข้อผิดพลาดระหว่างการพัฒนา และทำให้สามารถสลับการตั้งค่าระหว่างโครงการได้ง่าย

SISAHYGO แนะนำให้แยกข้อมูล Configuration ออกจาก Source Code และใช้ Environment Variables สำหรับข้อมูลที่มีความสำคัญ เช่น API Key และ Base URL


Figure 4-3 Development Environment ​

Figure 4-3

Figure 4-3 แสดงองค์ประกอบของ Development Environment ประกอบด้วย Source Code, Environment Variables, API Client และการเชื่อมต่อผ่าน HTTPS ไปยัง SISAHYGO API


Recommended Development Tools ​

ToolPurpose
VS Codeพัฒนาโปรแกรม
Postmanทดสอบ API
GitVersion Control
JSON Viewerตรวจสอบข้อมูล JSON
REST Clientทดลองเรียก API

Environment Variables ​

แนะนำให้จัดเก็บ Configuration ดังตัวอย่าง

env
SISAHYGO_API_URL=https://app.sisahygo.online/api/v1

SISAHYGO_API_KEY=sk_live_xxxxxxxxxxxxxxxxx

SISAHYGO_TIMEOUT=30

Project Configuration ​

ParameterValue
Base URLhttps://app.sisahygo.online/api/v1
ProtocolHTTPS
Data FormatJSON
AuthenticationAPI Key
Character EncodingUTF-8

Sample HTTP Header ​

http
X-API-Key: sk_live_xxxxxxxxxxxxxxxxx

Accept: application/json

Content-Type: application/json

Directory Recommendation ​

ตัวอย่างโครงสร้างสำหรับเก็บ Source Code

text
project/

├── src/

├── config/

├── services/

├── models/

├── logs/

├── .env

└── README.md

Key Points ​

ItemRecommendation
API KeyEnvironment Variables
Base URLConfiguration File
LoggingEnabled
HTTPSRequired

Implementation Notes ​

  • แยก Configuration ออกจาก Source Code
  • ห้าม Commit ไฟล์ .env
  • ใช้ HTTPS สำหรับทุก Request
  • กำหนด Timeout ที่เหมาะสมกับการเชื่อมต่อ

Best Practices ​

  • ใช้ Environment Variables สำหรับข้อมูลสำคัญ
  • จัดเก็บ API Key ในระบบ Secret Management หากมี
  • เปิดใช้งาน Logging ระหว่างการพัฒนา
  • ทดสอบการเชื่อมต่อด้วย Postman ก่อนเขียนโปรแกรม

Summary ​

Development Environment ที่ดีช่วยให้การพัฒนาเป็นมาตรฐาน ลดความผิดพลาด และเพิ่มความปลอดภัยของข้อมูลสำคัญ เช่น API Key และ Base URL


Next Step ​

➡️ 04.04 Your First API Call

SISAHYGO API Integration Guide