รูปแบบการตอบสนอง
ทุกเมธอดใน Steamworks Web API สามารถคืนค่าการตอบสนองได้หลายรูปแบบ โดยค่าเริ่มต้นแล้ว การตอบสนองทั้งหมดจะคืนค่ากลับมาโดยเข้ารหัสด้วย
JSON
อย่างไรก็ตาม แต่ละคำร้องขออาจมีพารามิเตอร์เสริม
format
เพื่อระบุรูปแบบการตอบสนองอย่างใดอย่างหนึ่งดังต่อไปนี้:
ตัวอย่าง:http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=440&count=1&format=xml
สามารถส่งค่าต่อไปนี้ให้กับพารามิเตอร์นี้ได้:
-
JSON
- API จะคืนค่าออบเจ็กต์ซึ่งบรรจุออบเจ็กต์ที่มีชื่อพร้อมข้อมูลผลลัพธ์ทุกครั้ง
- อาร์เรย์จะอยู่ในรูปแบบอาร์เรย์พร้อมชื่อประเภทของออบเจ็กต์ในอาร์เรย์
- ค่า Null จะอยู่ในรูปแบบ Null ของ JSON
- ตัวเลข 64 บิตจะคืนค่าในรูปแบบสตริง
- ตัวอย่าง:
{
"appnews": {
"appid": 440,
"newsitems": [
{
"gid": "1904306376092568991",
"title": "Prince of Prolander Event ",
"url": "http://store.steampowered.com/news/externalpost/tf2_blog/1904306376092568991",
"is_external_url": true,
"author": "",
"contents": "<a href=/"http://rgl.gg/default.aspx/"><img src=/"https://steamcdn-a.akamaihd.net/steam/news/29555/prince.png?t=1495219023/"></a><br><br>/n<p><b>This Sunday at 4:30pm EST</b> <a href=/"http://rgl.gg/default.aspx/" target=\"_blank\">RGL.gg</a> is hosting their Prince of Prolander event. See legendary players <a href=/"https://www.youtube.com/user/stabbyvideo/" target=\"_blank\">Stabby</a> and <a href=/"https://www.youtube.com/user/danethebrain/" target=\"_blank\">Uncle Dane</a> duke it out to answer the age old question: Who is better? Spies or Engies? Come see them settle the score once and for all in the new competitive TF2 format, Pick/Ban Prolander. Be sure to tune in to <a href=/"https://www.twitch.tv/extvesports/" target=\"_blank\">Twitch</a> this Sunday, and witness this historic event!</p><br>",
"feedlabel": "TF2 Blog",
"date": 1495218420,
"feedname": "tf2_blog",
"feed_type": 0,
"appid": 440
}
],
"count": 2385
}
}
-
XML
- ไม่ใช้แอตทริบิวต์ของ XML
- อาร์เรย์จะอยู่ในรูปแบบซีรีส์ขององค์ประกอบย่อยซึ่งบรรจุอยู่ในองค์ประกอบประเภทอาร์เรย์
- Null จะแสดงเป็นคำว่า "null" ระหว่างแท็กขององค์ประกอบ
- ตัวอย่าง:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE appnews>
<appnews>
<appid>440</appid>
<newsitems>
<newsitem>
<gid>1904306376092568991</gid>
<title>Prince of Prolander Event </title>
<url>http://store.steampowered.com/news/externalpost/tf2_blog/1904306376092568991</url>
<is_external_url>true</is_external_url>
<author/>
<contents><a href="http://rgl.gg/default.aspx"><img src="https://steamcdn-a.akamaihd.net/steam/news/29555/prince.png?t=1495219023"></a><br><br>
<p><b>This Sunday at 4:30pm EST</b> <a href="http://rgl.gg/default.aspx" target="_blank">RGL.gg</a> is hosting their Prince of Prolander event. See legendary players <a href="https://www.youtube.com/user/stabbyvideo" target="_blank">Stabby</a> and <a href="https://www.youtube.com/user/danethebrain" target="_blank">Uncle Dane</a> duke it out to answer the age old question: Who is better? Spies or Engies? Come see them settle the score once and for all in the new competitive TF2 format, Pick/Ban Prolander. Be sure to tune in to <a href="https://www.twitch.tv/extvesports" target="_blank">Twitch</a> this Sunday, and witness this historic event!</p><br></contents>
<feedlabel>TF2 Blog</feedlabel>
<date>1495218420</date>
<feedname>tf2_blog</feedname>
<feed_type>0</feed_type>
<appid>440</appid>
</newsitem>
</newsitems>
<count>2385</count>
</appnews>
-
VDF (Valve Data Format)
- นี่คือรูปแบบข้อมูลภายในของ Valve ซึ่งใช้ในเกมที่ทำงานด้วย Source Engine คำสั่ง GetSchema ของเกม TF2 จะคืนค่าข้อมูลที่มีลักษณะคล้ายกับ "items/.txt" (แม้ว่าคุณภาพจะไม่ขยายเป็นออบเจ็กต์ที่มีช่องข้อมูล "value")
- รับเอกสารประกอบได้ที่ วิกิของชุมชนผู้พัฒนา Valve และ วิกิอย่างเป็นทางการของ Team Fortress 2
- อาร์เรย์ในข้อมูลจะแสดงในรูปแบบอาร์เรย์ VDF ซึ่งมีชื่อของประเภทออบเจ็กต์ในอาร์เรย์ โดยอาร์เรย์ VDF จะเป็นออบเจ็กต์ซึ่งข้อมูลแต่ละรายการจะนำหน้าด้วยคีย์ตัวเลขในรูปแบบสตริงที่ล้อมด้วยเครื่องหมายคำพูด
- ค่า Null จะอยู่ในรูปแบบสตริงว่าง
- ตัวอย่าง:
"appnews"
{
"appid" "440"
"newsitems"
{
"0"
{
"gid" "1904306376092568991"
"title" "Prince of Prolander Event "
"url" "http://store.steampowered.com/news/externalpost/tf2_blog/1904306376092568991"
"is_external_url" "1"
"author" ""
"contents" "<a href=/"http://rgl.gg/default.aspx/"><img src=/"https://steamcdn-a.akamaihd.net/steam/news/29555/prince.png?t=1495219023/"></a><br><br>
<p><b>This Sunday at 4:30pm EST</b> <a href=/"http://rgl.gg/default.aspx/" target=\"_blank\">RGL.gg</a> is hosting their Prince of Prolander event. See legendary players <a href=/"https://www.youtube.com/user/stabbyvideo/" target=\"_blank\">Stabby</a> and <a href=/"https://www.youtube.com/user/danethebrain/" target=\"_blank\">Uncle Dane</a> duke it out to answer the age old question: Who is better? Spies or Engies? Come see them settle the score once and for all in the new competitive TF2 format, Pick/Ban Prolander. Be sure to tune in to <a href=/"https://www.twitch.tv/extvesports/" target=\"_blank\">Twitch</a> this Sunday, and witness this historic event!</p><br>"
"feedlabel" "TF2 Blog"
"date" "1495218420"
"feedname" "tf2_blog"
"feed_type" "0"
"appid" "440"
}
}
"count" "2385"
}
ควรใช้โซลูชันที่ยืดหยุ่นเพื่อแยกวิเคราะห์ผลลัพธ์ของ Web API เนื่องจากแต่ละเมธอดอาจคืนค่าผลลัพธ์ในลำดับที่ไม่เจาะจง
รหัสสถานะ HTTP
Steamworks Web API พยายามจะคืนค่าสถานะ HTTP ที่เหมาะสม ถ้าเป็นไปได้
รหัสที่พบได้ทั่วไปได้แก่:
รหัส | ข้อความ | คำอธิบาย |
200 | ตกลง | สำเร็จ! |
400 | คำร้องขอไม่ถูกต้อง | กรุณายืนยันว่าได้ส่งพารามิเตอร์ทั้งหมดที่จำเป็นแล้ว |
401 | ไม่ได้รับการอนุญาตสิทธิ์ | การเข้าถึงถูกปฏิเสธ การพยายามอีกครั้งจะไม่ช่วยอะไร กรุณายืนยันพารามิเตอร์ key= ของคุณ |
403 | ไม่อนุญาต | การเข้าถึงถูกปฏิเสธ การพยายามอีกครั้งจะไม่ช่วยอะไร กรุณายืนยันพารามิเตอร์ key= ของคุณ |
404 | ไม่พบผลลัพธ์ | ไม่มี API ที่ร้องขอ |
405 | เมธอดไม่ได้รับอนุญาต | มีการเรียก API นี้ด้วยเมธอด HTTP ที่ไม่ถูกต้อง เช่น GET หรือ PUSH |
429 | คำร้องขอมากเกินไป | คุณถูกจำกัดอัตราการใช้งาน |
500 | ข้อผิดพลาดภายในของเซิร์ฟเวอร์ | เกิดข้อผิดพลาดที่ไม่สามารถแก้ไขได้ กรุณาลองใหม่อีกครั้ง หากยังเกิดปัญหานี้อย่างต่อเนื่อง กรุณาโพสต์ไปที่ กระดานสนทนาผู้พัฒนา Steamworks พร้อมรายละเอียดเพิ่มเติมเกี่ยวกับคำร้องขอของคุณ |
503 | บริการไม่พร้อมใช้งาน | เซิร์ฟเวอร์ไม่พร้อมใช้งานชั่วคราว หรือกำลังทำงานจำนวนมากจนไม่สามารถตอบสนองได้ กรุณารอสักครู่ และลองใหม่อีกครั้งภายหลัง |