One of the ways you can create a REST endpoint in Drupal is by using Views. In this tutorial, we’ll add a REST endpoint display to a view of baseball players. We’ll examine and configure settings that are unique to the REST endpoint display.
By the end of this tutorial you should be able to:
- Add a REST endpoint display to a view
- Understand how to configure settings for an endpoint
Goal
Add a REST endpoint display to a view.
Prerequisites
To follow along with this tutorial, you should have Drupal installed with our database starting point imported. This will start you out with content and views that you can work with in this tutorial.
If you are new to Views, check out these User Guide tutorials as well:
Add a REST export display to the view of baseball players
With the help of some Drupal core modules, we can add a custom JSON endpoint to a Drupal site. In our case, we want to make our set of baseball players data consumable by other websites or apps. We’ll do this by adding a new REST export display to our existing Baseball Players view.
Install required modules
On Extend, locate the Web Services group of modules. Select the checkbox next to each of these modules (if not already selected), the select the Install button at the bottom of the page:
- RESTful Web Services
- Serialization
Edit view
Now we’re ready to add a new display to our view. Navigate to the Structure > Views (admin/structure/views). From our list of views, locate the view named Baseball Players and select Edit in the Operations column.
Add a REST export display
Near the top of the page, locate the Displays area. We have one display, Page. Next to the display named Page, select the + Add button to show a dropdown menu of the available display plugins.
From the display dropdown list, select REST export. This will cause the page to reload. Once the reload is complete, there will be a new display, REST export listed on our view next to Page, which is now ready to edit in the Views UI. (When you add a new display to a view, the Views UI will automatically switch you to that new display.)
(You’ll see an error message that says that the display uses a path but the path is undefined. We’ll be configuring the path in a later step.)
Configure serializer format settings
Let’s take a moment to look at the Format section of our view’s edit page. The current format for our new display is Serializer. This means the output for this display is going to be text that represents a more complex data structure.
Next to the Serializer format, select the Settings link. This will open a new modal window where we can configure which serialization format we would like our view to output.
Here we can configure the serialization format. Since we want our data to be available as JSON, select the checkbox labeled json
beneath the Accepted request formats label. Select the Apply button.
Read Comfy 501
Read Comfy 502
Read Comfy 503
Read Comfy 504
Read Comfy 505
Read Comfy 506
Read Comfy 507
Read Comfy 508
Read Comfy 509
Read Comfy 510
Read Comfy 511
Read Comfy 512
Read Comfy 513
Read Comfy 514
Read Comfy 515
Read Comfy 516
Read Comfy 517
Read Comfy 518
Read Comfy 519
Read Comfy 520
Read Comfy 521
Read Comfy 522
Read Comfy 523
Read Comfy 524
Read Comfy 525
Read Comfy 526
Read Comfy 527
Read Comfy 528
Read Comfy 529
Read Comfy 530
Read Comfy 531
Read Comfy 532
Read Comfy 533
Read Comfy 534
Read Comfy 535
Read Comfy 536
Read Comfy 537
Read Comfy 538
Read Comfy 539
Read Comfy 540
Read Comfy 541
Read Comfy 542
Read Comfy 543
Read Comfy 544
Read Comfy 545
Read Comfy 546
Read Comfy 547
Read Comfy 548
Read Comfy 549
Read Comfy 550
Read Comfy 551
Read Comfy 552
Read Comfy 553
Read Comfy 554
Read Comfy 555
Read Comfy 556
Read Comfy 557
Read Comfy 558
Read Comfy 559
Read Comfy 560
Read Comfy 561
Read Comfy 562
Read Comfy 563
Read Comfy 564
Read Comfy 565
Read Comfy 566
Read Comfy 567
Read Comfy 568
Read Comfy 569
Read Comfy 570
Read Comfy 571
Read Comfy 572
Read Comfy 573
Read Comfy 574
Read Comfy 575
Read Comfy 576
Read Comfy 577
Read Comfy 578
Read Comfy 579
Read Comfy 580
Read Comfy 581
Read Comfy 582
Read Comfy 583
Read Comfy 584
Read Comfy 585
Read Comfy 586
Read Comfy 587
Read Comfy 588
Read Comfy 589
Read Comfy 590
Read Comfy 591
Read Comfy 592
Read Comfy 593
Read Comfy 594
Read Comfy 595
Read Comfy 596
Read Comfy 597
Read Comfy 598
Read Comfy 599
Read Comfy 600
Read Comfy 601
Read Comfy 602
Read Comfy 603
Read Comfy 604
Read Comfy 605
Read Comfy 606
Read Comfy 607
Read Comfy 608
Read Comfy 609
Read Comfy 610
Read Comfy 611
Read Comfy 612
Read Comfy 613
Read Comfy 614
Read Comfy 615
Read Comfy 616
Read Comfy 617
Read Comfy 618
Read Comfy 619
Read Comfy 620
Read Comfy 621
Read Comfy 622
Read Comfy 623
Read Comfy 624
Read Comfy 625
Read Comfy 626
Read Comfy 627
Read Comfy 628
Read Comfy 629
Read Comfy 630
Read Comfy 631
Read Comfy 632
Read Comfy 633
Read Comfy 634
Read Comfy 635
Read Comfy 636
Read Comfy 637
Read Comfy 638
Read Comfy 639
Read Comfy 640
Read Comfy 641
Read Comfy 642
Read Comfy 643
Read Comfy 644
Read Comfy 645
Read Comfy 646
Read Comfy 647
Read Comfy 648
Read Comfy 649
Read Comfy 650
Read Comfy 651
Read Comfy 652
Read Comfy 653
Read Comfy 654
Read Comfy 655
Read Comfy 656
Read Comfy 657
Read Comfy 658
Read Comfy 659
Read Comfy 660
Read Comfy 661
Read Comfy 662
Read Comfy 663
Read Comfy 664
Read Comfy 665
Read Comfy 666
Read Comfy 667
Read Comfy 668
Read Comfy 669
Read Comfy 670
Read Comfy 671
Read Comfy 672
Read Comfy 673
Read Comfy 674
Read Comfy 675
Read Comfy 676
Read Comfy 677
Read Comfy 678
Read Comfy 679
Read Comfy 680
Read Comfy 681
Read Comfy 682
Read Comfy 683
Read Comfy 684
Read Comfy 685
Read Comfy 686
Read Comfy 687
Read Comfy 688
Read Comfy 689
Read Comfy 690
Read Comfy 691
Read Comfy 692
Read Comfy 693
Read Comfy 694
Read Comfy 695
Read Comfy 696
Read Comfy 697
Read Comfy 698
Read Comfy 699
Read Comfy 700
Read Comfy 701
Read Comfy 702
Read Comfy 703
Read Comfy 704
Read Comfy 705
Read Comfy 706
Read Comfy 707
Read Comfy 708
Read Comfy 709
Read Comfy 710
Read Comfy 711
Read Comfy 712
Read Comfy 713
Read Comfy 714
Read Comfy 715
Read Comfy 716
Read Comfy 717
Read Comfy 718
Read Comfy 719
Read Comfy 720
Read Comfy 721
Read Comfy 722
Read Comfy 723
Read Comfy 724
Read Comfy 725
Read Comfy 726
Read Comfy 727
Read Comfy 728
Read Comfy 729
Read Comfy 730
Read Comfy 731
Read Comfy 732
Read Comfy 733
Read Comfy 734
Read Comfy 735
Read Comfy 736
Read Comfy 737
Read Comfy 738
Read Comfy 739
Read Comfy 740
Read Comfy 741
Read Comfy 742
Read Comfy 743
Read Comfy 744
Read Comfy 745
Read Comfy 746
Read Comfy 747
Read Comfy 748
Read Comfy 749
Read Comfy 750
Read Comfy 751
Read Comfy 752
Read Comfy 753
Read Comfy 754
Read Comfy 755
Read Comfy 756
Read Comfy 757
Read Comfy 758
Read Comfy 759
Read Comfy 760
Read Comfy 761
Read Comfy 762
Read Comfy 763
Read Comfy 764
Read Comfy 765
Read Comfy 766
Read Comfy 767
Read Comfy 768
Read Comfy 769
Read Comfy 770
Read Comfy 771
Read Comfy 772
Read Comfy 773
Read Comfy 774
Read Comfy 775
Read Comfy 776
Read Comfy 777
Read Comfy 778
Read Comfy 779
Read Comfy 780
Read Comfy 781
Read Comfy 782
Read Comfy 783
Read Comfy 784
Read Comfy 785
Read Comfy 786
Read Comfy 787
Read Comfy 788
Read Comfy 789
Read Comfy 790
Read Comfy 791
Read Comfy 792
Read Comfy 793
Read Comfy 794
Read Comfy 795
Read Comfy 796
Read Comfy 797
Read Comfy 798
Read Comfy 799
Read Comfy 800
Read Comfy 801
Read Comfy 802
Read Comfy 803
Read Comfy 804
Read Comfy 805
Read Comfy 806
Read Comfy 807
Read Comfy 808
Read Comfy 809
Read Comfy 810
Read Comfy 811
Read Comfy 812
Read Comfy 813
Read Comfy 814
Read Comfy 815
Read Comfy 816
Read Comfy 817
Read Comfy 818
Read Comfy 819
Read Comfy 820
Read Comfy 821
Read Comfy 822
Read Comfy 823
Read Comfy 824
Read Comfy 825
Read Comfy 826
Read Comfy 827
Read Comfy 828
Read Comfy 829
Read Comfy 830
Read Comfy 831
Read Comfy 832
Read Comfy 833
Read Comfy 834
Read Comfy 835
Read Comfy 836
Read Comfy 837
Read Comfy 838
Read Comfy 839
Read Comfy 840
Read Comfy 841
Read Comfy 842
Read Comfy 843
Read Comfy 844
Read Comfy 845
Read Comfy 846
Read Comfy 847
Read Comfy 848
Read Comfy 849
Read Comfy 850
Read Comfy 851
Read Comfy 852
Read Comfy 853
Read Comfy 854
Read Comfy 855
Read Comfy 856
Read Comfy 857
Read Comfy 858
Read Comfy 859
Read Comfy 860
Read Comfy 861
Read Comfy 862
Read Comfy 863
Read Comfy 864
Read Comfy 865
Read Comfy 866
Read Comfy 867
Read Comfy 868
Read Comfy 869
Read Comfy 870
Read Comfy 871
Read Comfy 872
Read Comfy 873
Read Comfy 874
Read Comfy 875
Read Comfy 876
Read Comfy 877
Read Comfy 878
Read Comfy 879
Read Comfy 880
Read Comfy 881
Read Comfy 882
Read Comfy 883
Read Comfy 884
Read Comfy 885
Read Comfy 886
Read Comfy 887
Read Comfy 888
Read Comfy 889
Read Comfy 890
Read Comfy 891
Read Comfy 892
Read Comfy 893
Read Comfy 894
Read Comfy 895
Read Comfy 896
Read Comfy 897
Read Comfy 898
Read Comfy 899
Read Comfy 900
Read Comfy 901
Read Comfy 902
Read Comfy 903
Read Comfy 904
Read Comfy 905
Read Comfy 906
Read Comfy 907
Read Comfy 908
Read Comfy 909
Read Comfy 910
Read Comfy 911
Read Comfy 912
Read Comfy 913
Read Comfy 914
Read Comfy 915
Read Comfy 916
Read Comfy 917
Read Comfy 918
Read Comfy 919
Read Comfy 920
Read Comfy 921
Read Comfy 922
Read Comfy 923
Read Comfy 924
Read Comfy 925
Read Comfy 926
Read Comfy 927
Read Comfy 928
Read Comfy 929
Read Comfy 930
Read Comfy 931
Read Comfy 932
Read Comfy 933
Read Comfy 934
Read Comfy 935
Read Comfy 936
Read Comfy 937
Read Comfy 938
Read Comfy 939
Read Comfy 940
Read Comfy 941
Read Comfy 942
Read Comfy 943
Read Comfy 944
Read Comfy 945
Read Comfy 946
Read Comfy 947
Read Comfy 948
Read Comfy 949
Read Comfy 950
Read Comfy 951
Read Comfy 952
Read Comfy 953
Read Comfy 954
Read Comfy 955
Read Comfy 956
Read Comfy 957
Read Comfy 958
Read Comfy 959
Read Comfy 960
Read Comfy 961
Read Comfy 962
Read Comfy 963
Read Comfy 964
Read Comfy 965
Read Comfy 966
Read Comfy 967
Read Comfy 968
Read Comfy 969
Read Comfy 970
Read Comfy 971
Read Comfy 972
Read Comfy 973
Read Comfy 974
Read Comfy 975
Read Comfy 976
Read Comfy 977
Read Comfy 978
Read Comfy 979
Read Comfy 980
Read Comfy 981
Read Comfy 982
Read Comfy 983
Read Comfy 984
Read Comfy 985
Read Comfy 986
Read Comfy 987
Read Comfy 988
Read Comfy 989
Read Comfy 990
Read Comfy 991
Read Comfy 992
Read Comfy 993
Read Comfy 994
Read Comfy 995
Read Comfy 996
Read Comfy 997
Read Comfy 998
Read Comfy 999
Read Comfy 1000