บทนำ

Pexels API ช่วยให้สามารถเข้าถึงผ่านการโปรแกรมในไลบรารีเนื้อหา Pexels แบบเต็มรูปแบบ รวมถึงภาพถ่ายและวิดีโอ เนื้อหาทั้งหมดให้บริการฟรี และคุณสามารถใช้เนื้อหา Pexels สำหรับสิ่งที่คุณต้องการได้ ตราบใดที่เนื้อหานั้นอยู่ใน คู่มือ

Pexels API เป็น RESTful JSON API และคุณสามารถโต้ตอบได้จากภาษาหรือเฟรมเวิร์กใดก็ได้ด้วยไลบรารี HTTP หรืออีกวิธีหนึ่ง Pexels ยังมี ไลบรารีไคลเอ็นต์ ทางการจำนวนหนึ่งที่คุณสามารถใช้งานได้

หากคุณมีคำถามใดๆ อย่าลังเลที่จะตรวจสอบ คำถามที่พบบ่อย ของเรา หรือส่งอีเมลถึงเราได้ที่ [email protected]

Note: For historical reasons, all endpoints begin with https://api.pexels.com/v1/ except for video endpoints, which begin with https://api.pexels.com/videos/. Please see the individual endpoints listed below for more details about how to call each endpoint.

คู่มือ

เมื่อไหร่ก็ตามที่คุณทำคำขอ API ตรวจสอบให้มั่นใจว่าได้แสดง ลิงก์ที่ตรงไปยัง Pexels คุณสามารถใช้ลิงก์ข้อความ (เช่น "ภาพถ่ายจาก Pexels) หรือลิงก์ที่มีโลโก้ของเรา

ให้เครดิตกับช่างภาพของเราทุกครั้ง (เช่น "ภาพถ่ายโดย จอห์น โด จาก Pexels" พร้อมลิงก์ไปยังเพจภาพถ่ายใน Pexels)

คุณไม่สามารถคัดลอกหรือทำซ้ำฟังก์ชันการทำงานหลักของ Pexels (รวมถึงการทำให้เนื้อหา Pexels พร้อมใช้งานเป็นแอปวอลเปเปอร์)

ห้ามใช้ API ในทางที่ผิด ตามค่าเริ่มต้น API จะจำกัดอัตราที่ 200 คำขอต่อชั่วโมงและ 20,000 คำขอต่อเดือน คุณสามารถติดต่อเราเพื่อขอขีดจำกัดที่สูงขึ้น แต่กรุณาใส่ตัวอย่างหรือเตรียมที่จะให้ เดโมที่แสดงให้เห็นอย่างชัดเจนว่าคุณใช้ API กับการระบุแหล่งที่มา หากคุณได้ปฏิบัติตามข้อกำหนดของ API แล้วคุณสามารถรับคำขอแบบไม่จำกัดได้ฟรี

การใช้ Pexels API ในทางที่ผิด ที่รวมถึงการไม่จำกัดการพยายามหลีกเลี่ยงการจำกัดอัตราที่จะนำไปสู่การยุติการเข้าถึง API ของคุณ

Linking back to Pexels
1
2
3
4
5
6
7
8
9
10
11
12
13
<a href="https://www.pexels.com">Photos provided by Pexels</a>

<!-- or show our white logo -->

<a href="https://www.pexels.com">
  <img src="https://images.pexels.com/lib/api/pexels-white.png" />
</a>

<!-- or show our black logo -->

<a href="https://www.pexels.com">
  <img src="https://images.pexels.com/lib/api/pexels.png" />
</a>
Linking back to a Photo
1
This <a href="https://www.pexels.com/photo/food-dinner-lunch-meal-4147875">Photo</a> was taken by <a href="https://www.pexels.com/@daria">Daria</a> on Pexels.

ไลบรารีไคลเอ็นต์

Pexels มีไลบรารีไคลเอนต์ API อย่างเป็นทางการมากพอสมควรที่คุณสามารถใช้เพื่อโต้ตอบกับ Pexels API:

Language Package Github Changelog Version
Ruby rubygems pexels-ruby changelog 0.3.0
Javascript npm pexels-javascript changelog 1.2.1
.net nuget PexelsDotNetSDK changelog 1.0.6

โปรดอ่านข้อมูลเพิ่มเติมเกี่ยวกับไวยากรณ์ (ตัวอย่างโค้ดสำหรับแต่ละไลบรารีมีอยู่ในเอกสารนี้) ได้จากเอกสารสำหรับไลบรารีไคลเอ็นต์ที่คุณต้องการใช้ เรายินดีรับปัญหาและคำขอดึงข้อมูลบน Github!

หากคุณได้สร้างไลบรารี Pexels API อย่างไม่เป็นทางการสำหรับภาษาอื่น โปรดแจ้งให้เราทราบ!

การอนุญาต

จำเป็นต้องมีการอนุญาตสำหรับ Pexels API ทุกคนที่มีบัญชี Pexels สามารถ ขอคีย์ API ซึ่งคุณจะได้รับทันที

คำขอทั้งหมดที่คุณสร้างกับ API จะต้องระบุรหัสของคุณด้วย สิ่งนี้ให้มาโดยการเพิ่มส่วนหัวของ Authorization

Example of Authorization
1
2
curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/v1/search?query=people"

ร้องขอสถิติ

หากต้องการดูจำนวนคำขอที่เหลือในโควต้ารายเดือนของคุณ คำขอที่ประสบความสำเร็จจาก Pexels API จะมีส่วนหัว HTTP สามรายการ:

Response Header Meaning
X-Ratelimit-Limit ขีดจำกัดคำขอทั้งหมดของคุณสำหรับรอบเดือน
X-Ratelimit-Remaining คำขอเหล่านี้ยังเหลืออยู่จำนวนเท่าใด
X-Ratelimit-Reset ประทับเวลา UNIX ของช่วงเวลารายเดือนในปัจจุบันจะหมุนเวียนไป

หมายเหตุ: หัวเรื่องการตอบกลับเหล่านี้จะถูกส่งกลับเมื่อการตอบสนองได้สำเร็จ (2xx) เท่านั้น ไม่รวมอยู่ในการตอบกลับอื่นๆ รวมถึง 429 คำขอมากเกินไป ซึ่งบ่งชี้ว่าคุณเกินขีด จำกัดอัตราของคุณแล้ว โปรดอย่าลืมติดตาม X-Ratelimit-Remaining และ X-Ratelimit-Resetเพื่อจัดการขีดจำกัดคำขอของคุณ

Example of Rate Limit Headers
1
2
3
X-Ratelimit-Limit: 20000
X-Ratelimit-Remaining: 19684
X-Ratelimit-Reset: 1590529646

การแบ่งหน้า

คำขอ Pexels API ส่วนใหญ่จะส่งคืนระเบียนหลายรายการพร้อมกัน จุดสิ้นสุดทั้งหมดเหล่านี้มีการแบ่งหน้า และสามารถส่งคืนคำขอได้สูงสุดครั้งละ 80 รายการ แต่ละคำขอที่มีการแบ่งหน้าจะยอมรับพารามิเตอร์เดียวกัน และส่งคืนข้อมูลการแบ่งหน้าเดียวกันในการตอบกลับ

หมายเหตุ: แอตทริบิวต์การตอบกลับ prev_page และ next_pageจะถูกส่งกลับก็ต่อเมื่อมีหน้าที่ตรงกัน

Pagination Request Parameters
1
GET https://api.pexels.com/v1/curated?page=2&per_page=40
Pagination Response Attributes
1
2
3
4
5
6
7
{
  "page": 2,
  "per_page": 40,
  "total_results": 8000,
  "next_page": "https://api.pexels.com/v1/curated?page=3&per_page=40",
  "prev_page": "https://api.pexels.com/v1/curated?page=1&per_page=40"
}

แหล่งข้อมูลภาพถ่าย

แหล่ง Photo คือภาพถ่าย Pexels ในฟอร์แมต JSON จุดสิ้นสุด Photo API จะตอบสนองด้วยข้อมูลภาพถ่ายที่จัดฟอร์แมตในรูปทรงนี้

การตอบสนอง

แหล่งข้อมูลภาพถ่าย
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "id": 2014422,
  "width": 3024,
  "height": 3024,
  "url": "https://www.pexels.com/photo/brown-rocks-during-golden-hour-2014422/",
  "photographer": "Joey Farina",
  "photographer_url": "https://www.pexels.com/@joey",
  "photographer_id": 680589,
  "avg_color": "#978E82",
  "src": {
    "original": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg",
    "large2x": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
    "large": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",
    "medium": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&h=350",
    "small": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&h=130",
    "portrait": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800",
    "landscape": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200",
    "tiny": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280"
  },
  "liked": false,
  "alt": "Brown Rocks During Golden Hour"
}

ภาพถ่ายได้รับการคัดสรร

GET https://api.pexels.com/v1/curated

จุดสิ้นสุดนี้ช่วยให้คุณได้รับภาพถ่ายแบบเรียลไทม์ที่คัดสรรโดยทีมของ Pexels

เราเพิ่มภาพถ่ายใหม่อย่างน้อยหนึ่งภาพต่อชั่วโมงไปในรายการที่คัดสรรของเรา เพื่อให้คุณได้รับภาพถ่ายที่ได้รับความนิยมที่เปลี่ยนแปลงตลอดเวลา

พารามิเตอร์

การตอบสนอง

ตัวอย่างคำขอ
1
2
curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/v1/curated?per_page=1"
ตัวอย่างการตอบสนอง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "page": 1,
  "per_page": 1,
  "photos": [
    {
      "id": 2880507,
      "width": 4000,
      "height": 6000,
      "url": "https://www.pexels.com/photo/woman-in-white-long-sleeved-top-and-skirt-standing-on-field-2880507/",
      "photographer": "Deden Dicky Ramdhani",
      "photographer_url": "https://www.pexels.com/@drdeden88",
      "photographer_id": 1378810,
      "avg_color": "#7E7F7B",
      "src": {
        "original": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg",
        "large2x": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
        "large": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",
        "medium": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&h=350",
        "small": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&h=130",
        "portrait": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800",
        "landscape": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200",
        "tiny": "https://images.pexels.com/photos/2880507/pexels-photo-2880507.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280"
      },
      "liked": false,
      "alt": "Brown Rocks During Golden Hour"
    }
  ],
  "next_page": "https://api.pexels.com/v1/curated/?page=2&per_page=1"
}

รับภาพถ่าย

GET https://api.pexels.com/v1/photos/:id

เรียก Photo เฉพาะจาก id

พารามิเตอร์

การตอบสนอง

Returns a Photo object

ตัวอย่างคำขอ
1
2
curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/v1/photos/2014422"
ตัวอย่างการตอบสนอง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "id": 2014422,
  "width": 3024,
  "height": 3024,
  "url": "https://www.pexels.com/photo/brown-rocks-during-golden-hour-2014422/",
  "photographer": "Joey Farina",
  "photographer_url": "https://www.pexels.com/@joey",
  "photographer_id": 680589,
  "avg_color": "#978E82",
  "src": {
    "original": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg",
    "large2x": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
    "large": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",
    "medium": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&h=350",
    "small": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&h=130",
    "portrait": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800",
    "landscape": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200",
    "tiny": "https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280"
  },
  "liked": false,
  "alt": "Brown Rocks During Golden Hour"
}

แหล่งข้อมูลวิดีโอ

แหล่งข้อมูล Video คือวิดีโอ Pexels ในฟอร์แมต JSON จุดสิ้นสุด Photo API จะตอบสนองด้วยข้อมูลวิดีโอที่จัดฟอร์แมตในรูปทรงนี้

การตอบสนอง

แหล่งข้อมูลวิดีโอ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
  "id": 2499611,
  "width": 1080,
  "height": 1920,
  "url": "https://www.pexels.com/video/2499611/",
  "image": "https://images.pexels.com/videos/2499611/free-video-2499611.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb",
  "full_res": null,
  "tags": [],
  "duration": 22,
  "user": {
    "id": 680589,
    "name": "Joey Farina",
    "url": "https://www.pexels.com/@joey"
  },
  "video_files": [
    {
      "id": 125004,
      "quality": "hd",
      "file_type": "video/mp4",
      "width": 1080,
      "height": 1920,
      "fps": 23.976,
      "link": "https://player.vimeo.com/external/342571552.hd.mp4?s=6aa6f164de3812abadff3dde86d19f7a074a8a66&profile_id=175&oauth2_token_id=57447761"
    },
    {
      "id": 125005,
      "quality": "sd",
      "file_type": "video/mp4",
      "width": 540,
      "height": 960,
      "fps": 23.976,
      "link": "https://player.vimeo.com/external/342571552.sd.mp4?s=e0df43853c25598dfd0ec4d3f413bce1e002deef&profile_id=165&oauth2_token_id=57447761"
    },
    {
      "id": 125006,
      "quality": "sd",
      "file_type": "video/mp4",
      "width": 240,
      "height": 426,
      "fps": 23.976,
      "link": "https://player.vimeo.com/external/342571552.sd.mp4?s=e0df43853c25598dfd0ec4d3f413bce1e002deef&profile_id=139&oauth2_token_id=57447761"
    }
    ...
  ],
  "video_pictures": [
    {
      "id": 308178,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-0.jpg",
      "nr": 0
    },
    {
      "id": 308179,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-1.jpg",
      "nr": 1
    },
    {
      "id": 308180,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-2.jpg",
      "nr": 2
    },
    {
      "id": 308181,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-3.jpg",
      "nr": 3
    }
    ...
  ]
}

รับวิดีโอ

GET https://api.pexels.com/videos/videos/:id

เรียก Video เฉพาะจาก id

พารามิเตอร์

การตอบสนอง

Returns a Video object

ตัวอย่างคำขอ
1
2
curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/videos/videos/2499611"
ตัวอย่างการตอบสนอง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
  "id": 2499611,
  "width": 1080,
  "height": 1920,
  "url": "https://www.pexels.com/video/2499611/",
  "image": "https://images.pexels.com/videos/2499611/free-video-2499611.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb",
  "duration": 22,
  "user": {
    "id": 680589,
    "name": "Joey Farina",
    "url": "https://www.pexels.com/@joey"
  },
  "video_files": [
    {
      "id": 125004,
      "quality": "hd",
      "file_type": "video/mp4",
      "width": 1080,
      "height": 1920,
      "link": "https://player.vimeo.com/external/342571552.hd.mp4?s=6aa6f164de3812abadff3dde86d19f7a074a8a66&profile_id=175&oauth2_token_id=57447761"
    },
    {
      "id": 125005,
      "quality": "sd",
      "file_type": "video/mp4",
      "width": 540,
      "height": 960,
      "link": "https://player.vimeo.com/external/342571552.sd.mp4?s=e0df43853c25598dfd0ec4d3f413bce1e002deef&profile_id=165&oauth2_token_id=57447761"
    },
    {
      "id": 125006,
      "quality": "sd",
      "file_type": "video/mp4",
      "width": 240,
      "height": 426,
      "link": "https://player.vimeo.com/external/342571552.sd.mp4?s=e0df43853c25598dfd0ec4d3f413bce1e002deef&profile_id=139&oauth2_token_id=57447761"
    },
    {
      "id": 125007,
      "quality": "hd",
      "file_type": "video/mp4",
      "width": 720,
      "height": 1280,
      "link": "https://player.vimeo.com/external/342571552.hd.mp4?s=6aa6f164de3812abadff3dde86d19f7a074a8a66&profile_id=174&oauth2_token_id=57447761"
    },
    {
      "id": 125008,
      "quality": "sd",
      "file_type": "video/mp4",
      "width": 360,
      "height": 640,
      "link": "https://player.vimeo.com/external/342571552.sd.mp4?s=e0df43853c25598dfd0ec4d3f413bce1e002deef&profile_id=164&oauth2_token_id=57447761"
    },
    {
      "id": 125009,
      "quality": "hls",
      "file_type": "video/mp4",
      "width": null,
      "height": null,
      "link": "https://player.vimeo.com/external/342571552.m3u8?s=53433233e4176eead03ddd6fea04d9fb2bce6637&oauth2_token_id=57447761"
    }
  ],
  "video_pictures": [
    {
      "id": 308178,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-0.jpg",
      "nr": 0
    },
    {
      "id": 308179,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-1.jpg",
      "nr": 1
    },
    {
      "id": 308180,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-2.jpg",
      "nr": 2
    },
    {
      "id": 308181,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-3.jpg",
      "nr": 3
    },
    {
      "id": 308182,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-4.jpg",
      "nr": 4
    },
    {
      "id": 308183,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-5.jpg",
      "nr": 5
    },
    {
      "id": 308184,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-6.jpg",
      "nr": 6
    },
    {
      "id": 308185,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-7.jpg",
      "nr": 7
    },
    {
      "id": 308186,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-8.jpg",
      "nr": 8
    },
    {
      "id": 308187,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-9.jpg",
      "nr": 9
    },
    {
      "id": 308188,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-10.jpg",
      "nr": 10
    },
    {
      "id": 308189,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-11.jpg",
      "nr": 11
    },
    {
      "id": 308190,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-12.jpg",
      "nr": 12
    },
    {
      "id": 308191,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-13.jpg",
      "nr": 13
    },
    {
      "id": 308192,
      "picture": "https://static-videos.pexels.com/videos/2499611/pictures/preview-14.jpg",
      "nr": 14
    }
  ]
}

ภาพรวม

คอลเลกชัน Pexels เป็นวิธีการจัดกลุ่มภาพถ่ายและวิดีโอที่เฉพาะเจาะจงให้เป็นแกลเลอรีที่รวมเป็นหนึ่งเดียวกัน ซึ่งจะมีประโยชน์ เช่น หากคุณต้องการเปิดเผยเนื้อหา Pexels บางส่วนให้กับผู้ใช้ของคุณ คุณสามารถเข้าถึงคอลเลกชันและสื่อทั้งหมดของคุณผ่าน Pexels API ได้

หมายเหตุ: ไม่สามารถสร้างหรือแก้ไขคอลเลกชันโดยใช้ Pexels API แต่คุณสามารถจัดการคอลเลกชันของคุณบนเว็บไซต์ Pexels และแอป iOS หรือ Android ได้ API ให้คุณเข้าถึง คอลเลกชันเด่น และ คอลเลกชันของคุณเอง เท่านั้น

แหล่งข้อมูลคอลเล็กชัน

แหล่งข้อมูล Collection คือคอลเล็กชัน Pexels ในฟอร์แมต JSON จุดสิ้นสุดรายการคอลเลกชันจะตอบสนองด้วยข้อมูลวิดีโอที่จัดฟอร์แมตในรูปทรงนี้

การตอบสนอง

แหล่งข้อมูลคอลเล็กชัน
1
2
3
4
5
6
7
8
9
{
  "id": "8xntbhr",
  "title": "Hello Spring",
  "description": "Baby chicks, rabbits & pretty flowers. What's not to love?",
  "private": false,
  "media_count": 130,
  "photos_count": 121,
  "videos_count": 9
}

คอลเลกชันของฉัน

GET https://api.pexels.com/v1/collections

จุดสิ้นสุดนี้ส่งคืนคอลเล็กชันทั้งหมดของคุณ

พารามิเตอร์

การตอบสนอง

ตัวอย่างคำขอ
1
2
curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/v1/collections?per_page=1"
ตัวอย่างการตอบสนอง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "collections": [
    {
      "id": "9mp14cx",
      "title": "Cool Cats",
      "description": null,
      "private": false,
      "media_count": 6,
      "photos_count": 5,
      "videos_count": 1
    }
  ],

  "page": 2,
  "per_page": 1,
  "total_results": 5,
  "next_page": "https://api.pexels.com/v1/collections/?page=3&per_page=1",
  "prev_page": "https://api.pexels.com/v1/collections/?page=1&per_page=1"
}

สื่อคอลเลกชัน

GET https://api.pexels.com/v1/collections/:id

จุดสิ้นสุดนี้จะส่งคืนสื่อทั้งหมด (ภาพถ่ายและวิดีโอ) ภายในคอลเล็กชันเดียว คุณสามารถกรองเพื่อรับเฉพาะภาพถ่ายหรือวิดีโอโดยใช้พารามิเตอร์. ชนิด

พารามิเตอร์

การตอบสนอง

ตัวอย่างคำขอ
1
2
curl -H "Authorization: YOUR_API_KEY" \
  "https://api.pexels.com/v1/collections/9mp14cx?per_page=1&sort=desc"
ตัวอย่างการตอบสนอง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{
  "id": "9mp14cx",
  "media": [
    {
      "type": "Photo",
      "id": 2061057,
      "width": 4850,
      "height": 3224,
      "url": "https://www.pexels.com/photo/gray-and-white-kitten-on-white-bed-2061057/",
      "photographer": "Tranmautritam",
      "photographer_url": "https://www.pexels.com/@tranmautritam",
      "photographer_id": 8509,
      "avg_color": "#BBBEC3",
      "src": {
        "original": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg",
        "large2x": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
        "large": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",
        "medium": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&h=350",
        "small": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&h=130",
        "portrait": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800",
        "landscape": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200",
        "tiny": "https://images.pexels.com/photos/2061057/pexels-photo-2061057.jpeg?auto=compress&cs=tinysrgb&dpr=1&fit=crop&h=200&w=280"
      },
      "liked": false
    },
    {
      "type": "Video",
      "id": 854982,
      "width": 1280,
      "height": 720,
      "duration": 11,
      "full_res": null,
      "tags": [],
      "url": "https://www.pexels.com/video/video-of-a-tabby-cat-854982/",
      "image": "https://images.pexels.com/videos/854982/free-video-854982.jpg?auto=compress&cs=tinysrgb&fit=crop&h=630&w=1200",
      "avg_color": null,
      "user": {
        "id": 2659,
        "name": "Pixabay",
        "url": "https://www.pexels.com/@pixabay"
      },
      "video_files": [
        {
          "id": 17755,
          "quality": "hd",
          "file_type": "video/mp4",
          "width": 1280,
          "height": 720,
          "link": "https://player.vimeo.com/external/199433617.hd.mp4?s=1770018c20604d41d60e4f574e7680a1bd15edb8&profile_id=174&oauth2_token_id=57447761"
        },
        {
          "id": 17756,
          "quality": "sd",
          "file_type": "video/mp4",
          "width": 640,
          "height": 360,
          "link": "https://player.vimeo.com/external/199433617.sd.mp4?s=457abd2452a52548b8c02c503a91035ce8a713f0&profile_id=164&oauth2_token_id=57447761"
        },
        {
          "id": 17757,
          "quality": "sd",
          "file_type": "video/mp4",
          "width": 960,
          "height": 540,
          "link": "https://player.vimeo.com/external/199433617.sd.mp4?s=457abd2452a52548b8c02c503a91035ce8a713f0&profile_id=165&oauth2_token_id=57447761"
        },
        {
          "id": 17758,
          "quality": "hls",
          "file_type": "video/mp4",
          "width": null,
          "height": null,
          "link": "https://player.vimeo.com/external/199433617.m3u8?s=115ec8875069ea6203ddca51dae78cebd934b86e&oauth2_token_id=57447761"
        }
      ],
      "video_pictures": [
        {
          "id": 19591,
          "nr": 0,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-0.jpg"
        },
        {
          "id": 19592,
          "nr": 1,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-1.jpg"
        },
        {
          "id": 19593,
          "nr": 2,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-2.jpg"
        },
        {
          "id": 19594,
          "nr": 3,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-3.jpg"
        },
        {
          "id": 19595,
          "nr": 4,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-4.jpg"
        },
        {
          "id": 19596,
          "nr": 5,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-5.jpg"
        },
        {
          "id": 19597,
          "nr": 6,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-6.jpg"
        },
        {
          "id": 19598,
          "nr": 7,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-7.jpg"
        },
        {
          "id": 19599,
          "nr": 8,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-8.jpg"
        },
        {
          "id": 19600,
          "nr": 9,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-9.jpg"
        },
        {
          "id": 19601,
          "nr": 10,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-10.jpg"
        },
        {
          "id": 19602,
          "nr": 11,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-11.jpg"
        },
        {
          "id": 19603,
          "nr": 12,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-12.jpg"
        },
        {
          "id": 19604,
          "nr": 13,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-13.jpg"
        },
        {
          "id": 19605,
          "nr": 14,
          "picture": "https://images.pexels.com/videos/854982/pictures/preview-14.jpg"
        }
      ]
    }
  ],
  "page": 2,
  "per_page": 2,
  "total_results": 6,
  "next_page": "https://api.pexels.com/v1/collections/9mp14cx/?page=3&per_page=2",
  "prev_page": "https://api.pexels.com/v1/collections/9mp14cx/?page=1&per_page=2"
}

บันทึกการเปลี่ยนแปลง

นี่คือรายการการเปลี่ยนแปลงที่สำคัญของ Pexels API

22-11-2023

  • Added sort query parameter to the /collections/:id endpoint.

15-09-2022

  • Added video_file.fps attribute for the Video resource.

14-12-2021

  • Added alt attribute to the Photo resource.
  • Added previously-exposed liked attribute to the Photo responses.

13-09-2021

  • Updated image attribute for the Video resource to use the correct orientation.
  • Updated video_picture.picture attribute for the Video resource to use the correct orientation.

12-08-2021

  • Added Featured Collections endpoint.
  • Updated /collections/:id. Returns a collection if the collection is featured or belongs to the authenticated user.

19-04-2021

  • Added Collections resource and endpoints.

11-12-2020

  • Added avg_color attribute to the Photo resource.

12-11-2020

  • Added orientation, size and color filters to Photo Search.
  • Added orientation and size filters to Video Search.

28-05-2020

  • Initial version of this documentation.
เลือกภาษาของคุณ: English Português Español Català Deutsch Italiano Français Svenska Bahasa Indonesia Polski 日本語 繁體中文 简体中文 한국어 ภาษาไทย Nederlands Magyar Tiếng Việt Čeština Dansk Suomi Українська Ελληνικά Română Norsk Slovenčina Türkçe Русский