-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathapiary.apib
More file actions
1878 lines (1312 loc) · 57.7 KB
/
apiary.apib
File metadata and controls
1878 lines (1312 loc) · 57.7 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
FORMAT: 1A
# Hex
The Hex API is based on REST, it is currently in beta and so can change at any time. This API is a specification with examples from the implementation at https://hex.pm/api. Parts of the specification are optional to implement and will be marked as such.
### Related specifications
The HTTP API is only one of the specifications that makes the package manager Hex. Keep in mind that the HTTP API is not required to be implemented for clients to be able to consume the repository. Repositories that doesn't allow public users to publish packages can have any mechanism for publishing to their repository. For publicly visible repositories, it is recommended to also implement the endpoints for browsing packages (/packages/\*).
Below is a list of related specifications:
* [Endpoints](https://github.com/hexpm/specifications/blob/master/endpoints.md)
* [ETS registry format](https://github.com/hexpm/specifications/blob/master/registry-v1.md) (Going to be deprecated)
* [New registry format](https://github.com/hexpm/specifications/blob/master/registry-v2.md)
* [Tarball format](https://github.com/hexpm/specifications/blob/master/package_tarball.md)
* [Package metadata](https://github.com/hexpm/specifications/blob/master/package_metadata.md)
### Media types
Custom media types are used in the API to let consumers choose the format of the data they wish to receive. This is done by adding one or more of the following types to the Accept header when you make a request.
The API supports two media types; JSON and Erlang. Hex media types look like this:
application/vnd.hex[+format]
The following are the accepted media types:
* application/json
* application/vnd.hex+json
* application/vnd.hex+erlang
The erlang media type is a safe subset of erlang terms serialized with [`erlang:term_to_binary/1`](http://www.erlang.org/doc/man/erlang.html#term_to_binary-1). The only allowed terms are maps, lists, tuples, numbers, binaries and booleans. Atoms are strictly not allowed.
### Rate limiting
The rate limiting allows you to make 100 requests per minute per IP, or 500 requests per minute for authenticated users. The limits are likely to change in the future and conditional requests that return `304 Not Modified` will not count against the limits.
The returned HTTP headers will tell you about your current rate limit status:
Header | Description
:---------------------- | :----------
`X-RateLimit-Limit` | The maximum number of requests that the consumer is permitted to make per minute.
`X-RateLimit-Remaining` | The remaining number of requests the consumer is allowed to make until reset.
`X-RateLimit-Reset` | The time at which the rate limit window reset in UNIX epoch.
### User Agent required
All API requests must include a valid `User-Agent` header. An invalid or missing header will return a `400 Bad Request` response. The name of the client and version should be included, an example of the official Mix client is `User-Agent: Hex/0.12.1 (Elixir/1.3.0) (OTP/19.0)`.
### Pagination
Requests on collection resources return paginated results. Requests that return multiple results may return up to 100 items. You can specify further pages with the `?page` parameter.
```
$ curl https://hex.pm/api/packages?page=2
```
Page numbering start from 1 and will by default return the first page.
### Conditional requests
Most responses return an `ETag` header. Many responses will also return a `Last-Modified` header, the notable exception being responses on collection resources. You can use the values provided in these headers to send conditional requests with `If-None-Match` or `If-Modified-Since`. If the resource has not changed, a `304 Not Modified` response will be returned.
### Authentication
There are three ways to authenticate requests in the Hex API: OAuth2 tokens obtained via the Device Authorization Grant, API tokens, or Basic Authentication with a username and password. Failed authentication attempts will return `401 Unauthorized`. Resources accessed without proper authentication will return a `403 Forbidden` except for some resources that return `404 Not Found` to prevent leaking sensitive data.
Any endpoint implementation for Hex should support SSL termination by default, to prevent user credentials from being intercepted by third parties.
##### OAuth2 Token
```
$ curl -H "Authorization: Bearer token" https://hex.pm/api
```
OAuth2 tokens are obtained via the [Device Authorization Grant (RFC 8628)](https://datatracker.ietf.org/doc/html/rfc8628). See the OAuth section below for details. OAuth2 tokens must be sent with the `Bearer` prefix in the `Authorization` header. OAuth tokens have read-only permissions by default; write operations require two-factor authentication via the `x-hex-otp` header.
##### API Token
```
$ curl -H "Authorization: token" https://hex.pm/api
```
API tokens can be created via the web interface or the `/keys` endpoint. They provide direct access without the OAuth flow.
##### Basic Authentication (Deprecated)
```
$ curl -u "username" https://hex.pm/api
```
Basic authentication is deprecated and only allowed on some resources, specifically ones used to generate API tokens. This is because basic authentication is computationally expensive and less secure than using API tokens. New integrations should use OAuth2 Device Authorization instead.
### Two-Factor Authentication (2FA)
Write operations may require two-factor authentication. When 2FA is required, the server will respond with `403 Forbidden` and a message indicating that a one-time password is needed. The client should then retry the request with the `x-hex-otp` header containing the TOTP code.
```
$ curl -H "Authorization: token" -H "x-hex-otp: 123456" https://hex.pm/api/publish
```
### Client errors
1. Sending invalid JSON or Erlang will result in `400 Bad Request`.
HTTP/1.1 400 Bad Request
{
"status": 400,
"message": "bad request"
}
2. Failed authentication attempts will result in `401 Unauthorized`.
HTTP/1.1 401 Unauthorized
{
"status": 401,
"message": "failed to authorize"
}
3. Making a request to a missing resource will result in `404 Not Found`.
HTTP/1.1 404 Not Found
{
"status": 404,
"message": "not found"
}
4. Validation errors or invalid parameters will return `422 Unprocessable Entity`.
HTTP/1.1 422 Unprocessable Entity
{
"status": 422,
"message": "validation failed",
"errors": {
"email": "has invalid format"
}
}
### Package search
By default search will do a wildcard match on the package name and full text search on the package description. If the search string is `nerves`, package names matching `*nerves*` will be found and packages having `nerves` or a stemmed version of the string in the description.
Search can also be performed on specific fields, for example: `name:nerves* extra:package,name,postgresql`.
The search fields are:
* `name` - Package name, can include the wildcard operator `*` at the end or start of the string.
* `description` - Full text search package description.
* `extra` - Comma-separated search on `extra` map in metadata. `extra:type,nerves` will match `{"type": "nerves"}`.
# Group API Index
## API Index [/]
### Get API Index [GET]
Returns available API endpoints and documentation URL.
+ Request
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes
+ `packages_url` (string, required) - URL template for packages collection
+ `package_url` (string, required) - URL template for a single package
+ `package_release_url` (string, required) - URL template for a package release
+ `package_owners_url` (string, required) - URL template for package owners
+ `keys_url` (string, required) - URL for API keys collection
+ `key_url` (string, required) - URL template for a single API key
+ `documentation_url` (string, required) - URL to API documentation
+ Body
{
"packages_url": "https://hex.pm/api/packages",
"package_url": "https://hex.pm/api/packages/{name}",
"package_release_url": "https://hex.pm/api/packages/{name}/releases/{version}",
"package_owners_url": "https://hex.pm/api/packages/{name}/owners",
"keys_url": "https://hex.pm/api/keys",
"key_url": "https://hex.pm/api/keys/{name}",
"documentation_url": "https://docs.hexpm.apiary.io"
}
# Group Users
Authenticated requests require a User account. A User is required to publish packages but not to consume packages from the package manager.
## Users collection [/users]
### Create a User [POST]
A successful user creation will send a confirmation email to the given email address. The email will contain a link to follow in order to confirm the email and activate the account. The account will be usable once activated.
A user can be recreated for a given `username` and `email` if it has not been activated yet.
API clients are required to include a text with a link to the [Hex Terms of Service](https://hex.pm/policies/termsofservice) that ensures users agree to the terms. If clients do not follow this requirement their access to the API may be limited. If using the API specification to sign up to non-official Hex services, this text is not required, but others services may have similar requirements.
+ Request (application/json)
+ Attributes
+ `username` (string, required) - Only allows any alphanumeric (`[A-Za-z0-9]`) and the following characters: `_-.`. Case insensitive.
+ `password` (string, required) - Should simply be a printable UTF-8 string
+ `email` (string, required) - Should be a valid email address
+ Header
Accept: application/json
+ Body
{
"username": "ericmj",
"password": "hunter42",
"email": "ericmj@mail.com"
}
+ Response 201 (application/json)
+ Attributes (User)
+ Header
Location: https://hex.pm/api/users/ericmj
+ Body
{
"username": "ericmj",
"email": "ericmj@mail.com",
"inserted_at": "2015-04-05T01:21:49Z",
"updated_at": "2015-04-05T01:21:49Z",
"url": "https://hex.pm/api/users/ericmj"
}
## User [/users/{username_or_email}]
+ Parameters
+ username_or_email: ericmj (string)
Can be either a username or the primary email address associated with a User
+ Attributes
+ `username` (string, required) - Only allows any alphanumeric (`[A-Za-z0-9]`) and the following characters: `_-.`. Case insensitive.
+ `email` (string, optional) - Primary email address, only included if set to public
+ `full_name` (string, optional) - User's full name
+ `handles` (object, optional) - Social media handles (keys are service names, values are URLs)
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ `updated_at` (string, required) - ISO8601-encoded timestamp
+ `url` (string, required)
+ `owned_packages` (object, optional) - Deprecated. Map of package names to their API URLs
+ `packages` (array, optional) - List of owned packages
+ (object)
+ `name` (string, required) - Package name
+ `repository` (string, required) - Repository name
+ `url` (string, required) - API URL
+ `html_url` (string, required) - Web URL
### Fetch a User [GET]
+ Request (application/json)
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes (User)
+ Body
{
"username": "ericmj",
"email": "ericmj@mail.com",
"full_name": "Eric Meadows-Jönsson",
"handles": {
"GitHub": "https://github.com/ericmj",
"Twitter": "https://twitter.com/emjii"
},
"inserted_at": "2015-04-05T01:21:49Z",
"updated_at": "2015-04-05T01:21:49Z",
"url": "https://hex.pm/api/users/ericmj",
"packages": [
{
"name": "ecto",
"repository": "hexpm",
"url": "https://hex.pm/api/packages/ecto",
"html_url": "https://hex.pm/packages/ecto"
}
],
"owned_packages": {
"ecto": "https://hex.pm/api/packages/ecto"
}
}
## Currently authenticated user [/users/me]
### Fetch currently authenticated user [GET]
+ Request (application/json)
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (User)
+ `organizations` (array, required) - Organizations user is member of.
+ (object)
+ `name` (string, required) - Organization name.
+ `role` (string, required) - Role in organization.
+ Body
{
"username": "ericmj",
"email": "ericmj@mail.com",
"organizations": [
{
"name": "acme",
"role": "admin"
}
],
"inserted_at": "2015-04-05T01:21:49Z",
"updated_at": "2015-04-05T01:21:49Z",
"url": "https://hex.pm/api/users/ericmj"
}
## User Audit Logs [/users/me/audit-logs]
### Fetch User Audit Logs [GET]
Returns audit logs for the currently authenticated user.
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (array)
+ (object)
+ `action` (string, required) - The action that was performed
+ `params` (object, optional) - Parameters associated with the action
+ `user_agent` (string, optional) - User agent of the request
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ Body
[{
"action": "key.generate",
"params": {
"name": "my_computer"
},
"user_agent": "Hex/2.0.0 (Elixir/1.14.0)",
"inserted_at": "2015-04-05T01:21:49Z"
}]
## Password reset [/users/{username_or_email}/reset]
+ Parameters
+ username_or_email: ericmj (string)
Can be either a username or the email address associated with a User
### Reset User password [POST]
Will start the process to reset a User's password. An email will be send to the User's primary email address containin a link to follow and will lead to a form where a new password can be chosen.
+ Request (application/json)
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 204 (application/json)
# Group Repositories
## Repositories Collection [/repos]
Returns all public repositories and, if authenticated, all repositories the user is member of.
### List all Repositories [GET]
+ Request
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes (array[Repository])
+ Body
[{
"name": "acme",
"inserted_at": "2015-03-24T20:31:35Z",
"updated_at": "2015-04-02T04:55:41Z"
}]
## Repository [/repos/{name}]
+ Parameters
+ name: acme (string) - Repository name
+ Attributes
+ `name` (string, required) - Repository name
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ `updated_at` (string, required) - ISO8601-encoded timestamp
### Fetch a Repository [GET]
+ Request
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes (Repository)
+ Body
{
"name": "acme",
"inserted_at": "2015-03-24T20:31:35Z",
"updated_at": "2015-04-02T04:55:41Z"
}
# Group Organizations
Organizations allow teams to manage private packages and members.
## Organizations Collection [/orgs]
### List all Organizations [GET]
Returns organizations the authenticated user is a member of.
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (array[Organization])
+ Body
[{
"name": "acme",
"billing_active": true,
"inserted_at": "2017-08-30T17:35:23Z",
"updated_at": "2017-08-30T17:35:23Z"
}]
## Organization [/orgs/{name}]
+ Parameters
+ name: acme (string) - Organization name
+ Attributes
+ `name` (string, required) - Organization name
+ `billing_active` (boolean, required) - Whether the organization has active billing
+ `seats` (number, optional) - Number of seats in the organization's plan
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ `updated_at` (string, required) - ISO8601-encoded timestamp
### Fetch an Organization [GET]
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (Organization)
+ Body
{
"name": "acme",
"billing_active": true,
"seats": 5,
"inserted_at": "2017-08-30T17:35:23Z",
"updated_at": "2017-08-30T17:35:23Z"
}
### Update an Organization [POST]
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Body
{
"seats": 10
}
+ Response 200 (application/json)
+ Attributes (Organization)
## Organization Audit Logs [/orgs/{name}/audit-logs]
+ Parameters
+ name: acme (string) - Organization name
### Fetch Organization Audit Logs [GET]
Returns audit logs for the organization.
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (array)
+ (object)
+ `action` (string, required) - The action that was performed
+ `params` (object, optional) - Parameters associated with the action
+ `user_agent` (string, optional) - User agent of the request
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ Body
[{
"action": "organization.member.add",
"params": {
"username": "newmember"
},
"user_agent": "Hex/2.0.0 (Elixir/1.14.0)",
"inserted_at": "2017-08-30T17:35:23Z"
}]
## Organization Members Collection [/orgs/{name}/members]
+ Parameters
+ name: acme (string) - Organization name
### List Organization Members [GET]
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (array)
+ (object)
+ `username` (string, required)
+ `email` (string, optional)
+ `role` (string, required) - One of: `admin`, `write`, `read`
+ `url` (string, required)
+ Body
[{
"username": "ericmj",
"email": "ericmj@mail.com",
"role": "admin",
"url": "https://hex.pm/api/users/ericmj"
}]
### Add Organization Member [POST]
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Body
{
"name": "newmember",
"role": "write"
}
+ Response 204
## Organization Member [/orgs/{name}/members/{username}]
+ Parameters
+ name: acme (string) - Organization name
+ username: ericmj (string) - Member username
### Get Organization Member [GET]
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes
+ `username` (string, required)
+ `email` (string, optional)
+ `role` (string, required) - One of: `admin`, `write`, `read`
+ `url` (string, required)
+ Body
{
"username": "ericmj",
"email": "ericmj@mail.com",
"role": "admin",
"url": "https://hex.pm/api/users/ericmj"
}
### Update Organization Member [POST]
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Body
{
"role": "admin"
}
+ Response 204
### Remove Organization Member [DELETE]
+ Request
This request requires authentication.
+ Header
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 204
# Group Packages
Packages are essentially a (unique) name with some associated metadata. Group releases are a way to group and structure package releases which will be covered later.
## Packages Collection [/packages{?sort,search}]
Also available under /repos/{repository} for packages belonging to a specific repository.
This collection is paginated.
### List all Packages [GET]
+ Parameters
+ sort: recent_downloads (enum[string], optional)
Sorting field
+ Default: name
+ Members
+ name - Package name, ascending
+ recent_downloads - Number of package downloads in the last 90 days, descending
+ total_downloads - Total number of package downloads, descending
+ downloads - Alias for `total_downloads`
+ inserted_at - Package insertion time, descending
+ updated_at - Package last update time, descending
+ search: phoenix (string, optional)
Search string, see "Package search" above
+ Request
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes (array[Package])
+ Body
[{
"name": "plug",
"repository": "hexpm",
"url": "https://hex.pm/api/packages/plug",
"html_url": "https://hex.pm/packages/plug",
"docs_html_url": "https://hexdocs.pm/plug/",
"meta": {
"links": {"GitHub": "https://github.com/elixir-plug/plug"},
"licenses": ["Apache-2.0"],
"description": "Compose web applications with functions",
"maintainers": []
},
"downloads": {
"all": 43,
"recent": 3092706,
"week": 14,
"day": 2
},
"releases": [{
"version": "1.16.1",
"url": "https://hex.pm/api/packages/plug/releases/1.16.1",
"has_docs": true,
"inserted_at": "2024-06-20T13:57:58.725910Z"
}],
"retirements": {},
"latest_version": "1.16.1",
"latest_stable_version": "1.16.1",
"configs": {
"mix.exs": "{:plug, \"~> 1.16\"}",
"rebar.config": "{plug, \"1.16.1\"}",
"erlang.mk": "dep_plug = hex 1.16.1"
},
"inserted_at": "2014-04-23T18:58:52.000000Z",
"updated_at": "2024-06-20T13:58:01.580817Z"
}]
## Package [/packages/{name}]
+ Parameters
+ name: plug (string) - Package name
+ Attributes
+ `name` (string, required) - Package name
+ `repository` (string, required) - Name of repository the package belongs to
+ `meta` (object, required) - Package metadata
+ `maintainers` (array[string], optional) - Package maintainers, this attribute is deprecated.
+ `links` (object, optional) - Links related to the package, key is the link name, value is the URL
+ `licenses` (array[string], optional) - Licenses that apply to the package
+ `description` (string, optional) - Package description, recommended to be a single paragraph
+ `downloads` (object, optional) - Number of package downloads
+ `all` (number, required) - All time
+ `recent` (number, required) - Last 90 days
+ `week` (number, required) - Last seven days
+ `day` (number, required) - Yesterday
+ `releases` (array, optional) - See Release for details
+ (object)
+ `version` (string, required)
+ `url` (string, required)
+ `has_docs` (boolean, required) - Whether this release has documentation
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ `retirements` (object, optional) - Map of version strings to retirement information
+ `owners` (array, optional) - Package owners (minimal user objects)
+ `latest_version` (string, required) - Latest version (including pre-releases)
+ `latest_stable_version` (string, optional) - Latest stable version (excluding pre-releases)
+ `configs` (object, required) - Dependency snippets for different build tools
+ `mix.exs` (string, required) - Mix dependency snippet
+ `rebar.config` (string, required) - Rebar3 dependency snippet
+ `erlang.mk` (string, required) - Erlang.mk dependency snippet
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ `updated_at` (string, required) - ISO8601-encoded timestamp
+ `url` (string, required)
+ `html_url` (string, optional)
+ `docs_html_url` (string, optional)
### Fetch a Package [GET]
+ Request
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes (Package)
+ Body
{
"name": "plug",
"repository": "hexpm",
"url": "https://hex.pm/api/packages/plug",
"html_url": "https://hex.pm/packages/plug",
"docs_html_url": "https://hexdocs.pm/plug",
"meta": {
"links": {"GitHub": "https://github.com/elixir-lang/plug"},
"licenses": ["Apache 2"],
"description": "A specification and conveniences for composable modules in between web applications"
},
"downloads": {
"all": 43,
"recent": 20,
"week": 14,
"day": 2
},
"releases": [{
"version": "0.4.1",
"url": "https://hex.pm/api/packages/plug/releases/0.4.1",
"has_docs": true,
"inserted_at": "2014-04-23T18:58:54Z"
}],
"retirements": {
"0.4.0": {
"reason": "security",
"message": "CVE-XXXX-YYYY, see https://example.com/advisory"
}
},
"owners": [{
"username": "ericmj",
"email": "ericmj@mail.com",
"url": "https://hex.pm/api/users/ericmj"
}],
"latest_version": "0.4.1",
"latest_stable_version": "0.4.1",
"configs": {
"mix.exs": "{:plug, \"~> 0.4.1\"}",
"rebar.config": "{plug, \"0.4.1\"}",
"erlang.mk": "dep_plug = hex 0.4.1"
},
"inserted_at": "2015-03-24T20:31:35Z",
"updated_at": "2015-04-02T04:55:41Z"
}
## Package Audit Logs [/packages/{name}/audit-logs]
Also available under /repos/{repository} for packages belonging to a specific repository.
+ Parameters
+ name: plug (string) - Package name
### Fetch Package Audit Logs [GET]
Returns audit logs for the package.
+ Request
This request requires authentication.
+ Header
Accept: application/json
Authorization: e2bfe5e65b9235acebe06df8027905c0
+ Response 200 (application/json)
+ Attributes (array)
+ (object)
+ `action` (string, required) - The action that was performed
+ `params` (object, optional) - Parameters associated with the action
+ `user_agent` (string, optional) - User agent of the request
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ Body
[{
"action": "release.publish",
"params": {
"package": "plug",
"version": "0.4.1"
},
"user_agent": "Hex/2.0.0 (Elixir/1.14.0)",
"inserted_at": "2014-04-23T18:58:54Z"
}]
# Group Package Release
A release has a (unique) version and belongs to a package. Associated with the release are it's content; the source code and related files required to build and use it as a library.
After a release has been published there is a one hour window where it can be modified (republished) or reverted. After the hour it is immutable and cannot be altered by users, note that the administrators reserve the right to remove or modify releases in any way, either because it breaks the Code of Conduct or because any of the specifications changed.
## Release [/packages/{name}/releases/{version}]
Also available under /repos/{repository} for packages belonging to a specific repository.
+ Parameters
+ name: plug (string)
Package name
+ version: 0.4.1 (string)
Release version, should be a [Semantic Version](http://semver.org/)
+ Attributes
+ `version` (string, required) - Release version, should be a [Semantic Version](http://semver.org/)
+ `checksum` (string, required) - SHA-256 checksum of the package tarball, hex-encoded (lowercase)
+ `has_docs` (boolean, required) - `true` if this release has associated documentation
+ `meta` (object, required) - Release metadata
+ `app` (string, required) - OTP application name
+ `build_tools` (array[string], required) - Names of build tools that can build the package
+ `elixir` (string, optional) - Elixir version requirement
+ `requirements` (object, required) - Release dependencies, keyed by package name
+ `{package_name}` (object, required)
+ `requirement` (string, required) - [Version requirement](http://elixir-lang.org/docs/stable/elixir/Version.html) on dependency
+ `optional` (boolean, required) - An optional dependency only has to be satisfied if a package higher up the chain also requires it
+ `app` (string, required) - OTP application name, usually the dependency name but can differ
+ `configs` (object, required) - Dependency snippets for different build tools
+ `mix.exs` (string, required) - Mix dependency snippet
+ `rebar.config` (string, required) - Rebar3 dependency snippet
+ `erlang.mk` (string, required) - Erlang.mk dependency snippet
+ `retirement` (object, optional) - Retirement status, if not set the release is not retired
+ `reason` (enum[string], required) - Reason for retirement
+ Members
+ `other`
+ `invalid`
+ `security`
+ `deprecated`
+ `renamed`
+ `message` (string, optional) - An additional, clarifying message for the retirement
+ `publisher` (object, optional) - User who published this release
+ `username` (string, required)
+ `email` (string, optional)
+ `url` (string, required)
+ `downloads` (number, required) - Number of downloads of the release
+ `inserted_at` (string, required) - ISO8601-encoded timestamp
+ `updated_at` (string, required) - ISO8601-encoded timestamp
+ `url` (string, required)
+ `html_url` (string, optional)
+ `docs_html_url` (string, optional)
+ `package_url` (string, required)
### Fetch a Release [GET]
+ Request
+ Header
Accept: application/json
+ Response 200 (application/json)
+ Attributes (Release)
+ Body
{
"version": "0.4.1",
"checksum": "abc123def456...",
"has_docs": true,
"url": "https://hex.pm/api/packages/plug/releases/0.4.1",
"package_url": "https://hex.pm/api/packages/plug",
"html_url": "https://hex.pm/packages/plug/0.4.1",
"docs_html_url": "https://hexdocs.pm/plug/0.4.1",
"meta": {
"app": "plug",
"build_tools": ["mix"],
"elixir": "~> 1.0"
},
"requirements": {
"cowboy": {
"requirement": "~> 1.0",
"optional": true,
"app": "cowboy"
}
},
"configs": {