-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapiary.apib
More file actions
4190 lines (3868 loc) · 152 KB
/
apiary.apib
File metadata and controls
4190 lines (3868 loc) · 152 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
HOST: https://api.policescorecard.org/v1
# API
* _Maintained By:_ __[Peter Schmalfeldt](https://peterschmalfeldt.com)__
* _Last Modified:_ __Feb 15th, 2025__
* _Current API Version:_ __v1.3.0__
# Group API Basics
## API Overview
Our API has a default Rate Limit by IP Address to `2500` calls per day. We add the following headers so you can monitor your API Rate:
* __X-Rate-Limit-Limit__: The rate limit ceiling for that given request
* __X-Rate-Limit-Remaining__: The number of requests left for the 24 hour window
* __X-Rate-Limit-Reset__: The remaining window before the rate limit resets in UTC [epoch seconds](http://en.wikipedia.org/wiki/Unix_time)
If a specific IP Address exceeds this limit, the API will return a 429 HTTP JSON Response Error. A sample of this is provided in the Artwork API endpoint.
## API Authentication
Our API requires an API Key to use. We are not providing API Keys to the general public at this time. You likely received an API Key before accessing this documentation, if not, please contact the individual who sent you here.
## You can set the API Key one of two ways
#### Request Header:
* __API-Key__ `243CEA2E-7E63-D2C4-3D2D-1A114288274B` _( this is not an actual API Key )_
#### GET Parameter:
* __?apikey=__ `243CEA2E-7E63-D2C4-3D2D-1A114288274B`
### HTTP Request Method Limits
### Common API Responses
The following parameters are available on every API endpoint and used for pagination
for if there are a lot of results.
+ `notices` (array, optional) - An array of API Notices. These notices are for the API to let the Developer know something that might be helpful, but will not impact the API results.
+ `warnings` (array, optional) - An array of API Warnings. These warnings explain why the API might have had issues returning results.
+ `errors` (array, optional) - An array of API Errors. These errors explain why the API prevented returning results.
+ `field_errors` (object, optional) - If the error was in regards to data entry, any errors specific to an input field will return here with the input name and error message.
+ `meta` (object) - The META data object that contains the basic information about the API response.
+ `meta.total` (number) - Total number of all results. Not just the number returned in the API call.
+ `meta.showing` (number) - Number of results returned in the current API call ( may be less than total results ).
+ `meta.pages` (number) - Number of pages of results. This is based on the `total` results divided by the `pageSize`.
+ `meta.page` (number) - Current Page
+ `data` (object or array) - This is the the actual data returned for the API call. For API calls that are expected to return a single result, the `data` will be an Object. For API calls that are expecting multiple items returned, `data` will be returned as an array ( even if there is only one item returned, such as search results, etc ).
+ `data.policescorecard_url` (string) - This will exist for results that have custom pages on the https://policescorecard.org website.
__Response 200:__ (application/json)
```
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 97,
"showing": 30,
"pages": 4,
"page": 1
},
"data": [
...
]
}
```
__Response 403:__ (application/json)
```
{
"notices": [],
"warnings": [],
"errors": ["Missing API Key"],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": []
}
```
### Optional API Params
The following parameters are available on most API endpoint and used for pagination
for if there are a lot of results.
+ `apikey` (string) - Your Police Scorecard API Key
+ `fields` (string) - Comma Separated List of fields you want in the response. By default all public fields will be returned, but if you only need specific fields you can greatly simplify your API response by specifying them.
+ `pageSize` (number, optional) - How many results to return in a single API call. Defaults to 30
+ `page` (number, optional) - If there is more than one page of results, you can set which page to load here
+ `sort` (optional, string, `population_rank`) - Comma Separated List of fields you want to sort by
+ `order` (optional, string, `asc`) - Comma Separated List of Order Methods
+ `pretty` (optional) - If you want to format the JSON response to be human readable, just add a `pretty` param in the API call ( it does not need a value )
### Request Authorization Header
* __Authorization:__ Bearer `token`
An example API Header would look like this:
```
curl --data '' https://api.policescorecard.org/v1/user/refresh/ -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOiIyIiwiaWF0IjoxNDUxNzEyNzg0LCJleHAiOjE0NTIzMTc1ODQsImlzcyI6IkRvaW5nIEFQSSJ9.x3eJutiulLnJCJkl_jP9ETj43ihePVeMtaWgWF0I60w"
```
# Group API Access
All access to our API will require an Authentication Token. The following endpoint will
get your access to endpoints that do not require user authentication.
## Token [/token]
You will not be able to make a request to our API without a `token` sent in an
Authorization Header. This `/token` endpoint is the only public endpoint open to
allow a `token` to be requested. This endpoint is only required for anonymous users
that have not logged in. Once the user logs in, you will need to use the `token` that
is sent back for that user, as it will be used for authenticating that specific user.
Once a user has logged in, you will need to send over their Authentication
Token in the HTTP Header. A `token` is returned with a successful login. A session
token is valid for 7 days. You can refresh your token to prevent having to log in
again by either adding the Request Authorization Header below, or using the
`/api/0.1/user/refresh/` endpoint.
### Get Token [GET]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Nzc5MjY2ODUsImV4cCI6MTU3ODUzMTQ4NSwiaXNzIjoiQVBJIn0.tC2KwBJyBDmyOuYCQjrmOYx0-KPPFKE6qC8sO3h09Sw"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Refresh Session [/user/refresh]
A `token` is returned with a successful login. A session token is valid for 7 days.
You can refresh your token to prevent having to log in again by either adding the
Request Authorization Header below. `token` should be the string returned in the
`token` parameter from a successful login.
* __Authorization:__ Bearer `token`
### Refresh Session [POST]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOjIsImlhdCI6MTQ1MTc5ODYyMSwiZXhwIjoxNDUyNDAzNDIxLCJpc3MiOiJEb2luZyBBUEkifQ.za4PspEZfeVxydO3QHSFBLm_9PcrCBRwK9HLofBY74s"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Invalid or expired token"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
# Group Account Management
The following endpoints are specifically setup to manage the logged in users account.
## Register [/user/register/?username={username}&password={password}&retype_password={retype_password}&inviteCode={inviteCode}&first_name={first_name}&last_name={last_name}&email={email}&agree={agree}]
API Endpoint to register new users. This should set the user's `activated` field
to `true` unless they've included their email address. If so, `activated` is
`false` and the user will be sent an email with a `new_email_key` key to confirm
their email address to complete registration.
+ Parameters
+ username (string, required) - The username or email address of the account
+ Min Length: __3__
+ Max Length: __30__
+ Characters Allowed: __a-zA-Z0-9___
+ Case Insensitive
+ password (string, required) - The password to the account
+ Min Length: __6__
+ No Other Password Requirements :)
+ retype_password (string, required) - The password to the account
+ Min Length: __6__
+ No Other Password Requirements :)
+ inviteCode (string, required) - During Alpha / Beta testing, an Invitation Code is Required for registration
+ Length: __6__
+ Existing Users: __hash_id__
+ first_name (string, optional) - First Name - NOTE: Apple does not like requiring personal info for registration
+ Min Length: __1__
+ Max Length: __50__
+ last_name (string, optional) - Last Name - NOTE: Apple does not like requiring personal info for registration
+ Min Length: __1__
+ Max Length: __50__
+ email (string, optional) - Email Address - NOTE: Apple does not like requiring personal info for registration
+ Min Length: __1__
+ Max Length: __100__
+ agree (string, required) - Agree to TOS - User Agreed to Terms of Service
### User Register [POST]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": false,
"banned": false,
"created_date": "2020-01-02T01:11:05.008Z",
"email": "john.doe@fake.com",
"first_name": "John",
"hash_id": "WJvqzv",
"id": 3,
"last_name": "Doe",
"modified_date": "2020-01-02T01:11:05.008Z",
"profile_name": "john_doe",
"username": "john_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {
"username": [
"Username is already in use"
],
"email": [
"Email is already in use"
]
},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Confirm Account [/user/confirm/account/?key={key}]
During account registration, new users will be sent a link to confirm their
email address. The users account will be disabled until the user confirms the email
address.
+ Parameters
+ key (required, string) - The `new_email_key` stored for the user
### Confirm Account [GET]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": true,
"banned": false,
"banned_reason": null,
"bio": null,
"company_name": null,
"created_date": "2020-01-02T02:10:23.000Z",
"deletedAt": null,
"email": "jane.doe@fake.com",
"first_name": "Jane",
"hash_id": "LYvlRm",
"id": 2,
"last_name": "Doe",
"location": null,
"modified_date": "2020-01-02T02:15:20.457Z",
"new_password_key": null,
"profile_link_1": null,
"profile_link_2": null,
"profile_link_3": null,
"profile_link_twitter": null,
"profile_link_website": null,
"profile_name": "jane_doe",
"profile_photo": null,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjIsImlhdCI6MTU3NzkzMTMyMCwiZXhwIjoxNTc4NTM2MTIwLCJpc3MiOiJBUEkifQ.GjxhhS7WLZcNrbnbULPZ1RiFUF_1ctMNZMxSx3k4Mkk",
"username": "jane_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Activation Key not found"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Confirm Email Change [/user/confirm/email/?key={key}]
When a user changes their email, they will be sent a confirmation email to both
their new and old email address assuring it was them that requested the email
change.
+ Parameters
+ key (required, string) - The `new_email_key` stored for the user
### Confirm Email Change [GET]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": true,
"banned": false,
"banned_reason": null,
"bio": null,
"company_name": null,
"created_date": "2020-01-02T02:10:23.000Z",
"deletedAt": null,
"email": "jane.doe2@fake.com",
"first_name": "Jane",
"hash_id": "LYvlRm",
"id": 2,
"last_name": "Doe",
"location": null,
"modified_date": "2020-01-02T02:26:45.454Z",
"new_password_key": null,
"profile_link_1": null,
"profile_link_2": null,
"profile_link_3": null,
"profile_link_twitter": null,
"profile_link_website": null,
"profile_name": "jane_doe",
"profile_photo": null,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjIsImlhdCI6MTU3NzkzMjAwNSwiZXhwIjoxNTc4NTM2ODA1LCJpc3MiOiJBUEkifQ.G0c_x6pt1djFAFyr9SY-3Q295NsMVgQu95hDSkc4h7s",
"username": "jane_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Confirmation Key not found"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Confirm Password Change [/user/confirm/password/?key={key}]
When a user changes their password, they will be sent a confirmation email assuring
it was them that requested the password change.
+ Parameters
+ key (required, string) - The `new_password_key` stored for the user
### Confirm Password Change [GET]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": true,
"banned": false,
"banned_reason": null,
"bio": null,
"company_name": null,
"created_date": "2020-01-02T02:10:23.000Z",
"deletedAt": null,
"email": "jane.doe@fake.com",
"first_name": "Jane",
"hash_id": "LYvlRm",
"id": 2,
"last_name": "Doe",
"location": null,
"modified_date": "2020-01-02T02:32:13.794Z",
"new_password_key": null,
"profile_link_1": null,
"profile_link_2": null,
"profile_link_3": null,
"profile_link_twitter": null,
"profile_link_website": null,
"profile_name": "jane_doe",
"profile_photo": null,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjIsImlhdCI6MTU3NzkzMjMzMywiZXhwIjoxNTc4NTM3MTMzLCJpc3MiOiJBUEkifQ.s_ykYP-rQuJJH41y7lZODWAc2RIamZGYw_GGPhwElD4",
"username": "jane_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Confirmation Key not found"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Login [/user/login/?username={username}&password={password}]
Some of the API endpoints will require authentication. Those endpoints will
require the `token` returned from a successful login.
To access authentication-protected endpoints, you will need to include an
`Authorization` HTTP header in the format: `Bearer (token)`.
+ Parameters
+ username (string, required) - The username of the account
+ password (string, required) - The password to the account
### User Login [POST]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": true,
"banned": false,
"banned_reason": null,
"bio": null,
"company_name": null,
"created_date": "2020-01-02T02:10:23.000Z",
"deletedAt": null,
"email": "jane.doe@fake.com",
"first_name": "Jane",
"hash_id": "LYvlRm",
"id": 2,
"last_name": "Doe",
"location": null,
"modified_date": "2020-01-02T02:32:13.000Z",
"new_password_key": null,
"profile_link_1": null,
"profile_link_2": null,
"profile_link_3": null,
"profile_link_twitter": null,
"profile_link_website": null,
"profile_name": "jane_doe",
"profile_photo": null,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjIsImlhdCI6MTU3NzkzNDA3MiwiZXhwIjoxNTc4NTM4ODcyLCJpc3MiOiJBUEkifQ.sHfJ-iFk1TZYPbO4MBneuFvyKu6PwkALSU-QcyvZLGc",
"username": "jane_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 401 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Incorrect Password"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Logout [/user/logout]
Tell API that the user has logged out. This will only register if a Bearer Authentication Token is set in the Header.
### User Logout [POST]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"success": true
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 403 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Invalid API Authorization Token"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Forgot Password [/user/forgot-password/?email={email}]
Forgot password will require an email address that is requesting for the password
reset link.
+ Parameters
+ email (required, string) - The email address of the account
### User Forgot Password [POST]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": true,
"banned": false,
"banned_reason": null,
"bio": null,
"company_name": null,
"created_date": "2020-01-02T02:10:23.000Z",
"deletedAt": null,
"email": "jane.doe@fake.com",
"first_name": "Jane",
"hash_id": "LYvlRm",
"id": 2,
"last_name": "Doe",
"location": null,
"modified_date": "2020-01-02T03:15:33.321Z",
"new_password_key": "RBiNnDqOJUaX",
"profile_link_1": null,
"profile_link_2": null,
"profile_link_3": null,
"profile_link_twitter": null,
"profile_link_website": null,
"profile_name": "jane_doe",
"profile_photo": null,
"username": "jane_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"No Matching Email Found"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Reset Password [/user/reset-password/?token={token}&password={password}&retype_password={retype_password}]
Reset password will check the token against the `new_password_key` column for that user. We will also likely want to make sure that `new_password_requested` is less than a certain age to prevent open password change requests.
+ Parameters
+ token (required, string) - This is the `new_password_key` token that is sent from the link in the email address.
+ password (required, string) - This is the new password that the user wants to reset
+ retype_password (required, string) - This should be the same as 'password' and is the confirmation of the password
### User Reset Password [POST]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": {
"activated": true,
"banned": false,
"banned_reason": null,
"bio": null,
"company_name": null,
"created_date": "2020-01-02T02:10:23.000Z",
"deletedAt": null,
"email": "jane.doe@fake.com",
"first_name": "Jane",
"hash_id": "LYvlRm",
"id": 2,
"last_name": "Doe",
"location": null,
"modified_date": "2020-01-02T03:52:48.714Z",
"new_password_key": null,
"profile_link_1": null,
"profile_link_2": null,
"profile_link_3": null,
"profile_link_twitter": null,
"profile_link_website": null,
"profile_name": "jane_doe",
"profile_photo": null,
"username": "jane_doe"
},
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Request Invalid or Expired"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Resend Email Confirmation [/user/resend-confirmation/{hash_id}]
If the user needs to resend their email confirmation, this is the endpoint to use.
+ Parameters
+ hash_id (required, string) - This is the hash id of the user
### Resend Email Confirmation [GET]
+ Response 200 (application/json)
{
"notices": [],
"warnings": [],
"errors": [],
"field_errors": {},
"meta": {
"total": 1,
"showing": 1,
"pages": 1,
"page": 1
},
"data": "Confirmation Email Resent",
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
+ Response 400 (application/json)
{
"notices": [],
"warnings": [],
"errors": [
"Invalid Request"
],
"field_errors": {},
"meta": {
"total": 0,
"showing": 0,
"pages": 1,
"page": 1
},
"data": null,
"attribution": {
"text": "Data Provided by Police Scorecard",
"website": "https://policescorecard.org",
"link": "<a href=\"https://policescorecard.org\">Data Provided by Police Scorecard</a>",
"license": "https://raw.githubusercontent.com/policescorecard/api/master/LICENSE",
"report_bug": "https://github.com/policescorecard/api/issues/new",
"logo": "https://cdn.policescorecard.org/common/logo.png",
"icon": "https://cdn.policescorecard.org/common/icon.png"
}
}
## Update Account [/user/update/?username={username}&password={password}&new_username={new_username}&new_email={new_email}&password_new={password_new}&password_new_retype={password_new_retype}]
This endpoint will allow the logged in user to update their own account. This uses the current Authentication Bearer Token to lookup who's account to update.
The Bearer Token is created during login and contains the users ID from our database. You will not be able to use this endpoint to manage anyone elses account except your own.
IMPORTANT NOTES ABOUT THIS ENDPOINT:
1. Changing the username will immediatley make the old username available to the world for use. We do check to make sure that the new username being requested is available.
2. We do not immediatley change the email when requested. Instead we send a confirmation email to both the new and old email to confirm the requested change.
3. We do not immediatley change the password when requested. We first send a confirmation email to the users current email to confirm that they made the requested change.
+ Parameters
+ username (required, string) - Current Account Username ( required to make any changes on this endpoint )
+ password (required, string) - Current Account Passsword ( required to make any changes on this endpoint )
+ new_username (optional, string) - New Username user wishes to change their username to