Code Sample

An API documentation example website

Sample Endpoint (with Method) Code Example:
GET /classical/findByManufacturer

/classical/findByManufacturer  is one of the APIdocexample.com API’s endpoints with just one method, a GET call that returns a list of classical guitars filtered by make (Ibanez, Cordoba, Yamaha, etc).

Request Parameters

This endpoint-with-method has the one parameter, manufacturer, and it is a required, query parameter (which is also its location in the Request URL, see more below). Its form is an array of the possible classical guitar makes, of the data type [string].

Try out a Request in the API’s Resources UI and View the curl Request Call

If you haven’t already be sure to spend time, in the APIdocexample.com Resources section, on the various guitar Resource documentation webpages—such as the classical Resource page at https://apidocexample.com/classical-resource/ . (These are in the form of interactive, Swagger UI webpages.)

While in the expanded GET /classical/findByManufacturer  section of that page, do the “Try it out” and “Execute” steps to view the responses from the system. Once you’ve selected, for example, Ibanez as your “Find classical guitar by manufacturer” choice and have hit execute, the feedback will include the following curl call that represents your findClassicalByManufacturer Request call:

·  curl -X GET “https://apidocexample.com/swagger/classical/findByManufacturer?manufacturer=Ibanez”
 -H “accept: application/json”

curl Request Call and Your Front-End Request GUI

Since curl (aka cURL) is a command-line tool providing a language-independent format for showing HTTP requests and responses, you can use it to build your Request UI in whatever front-end language you’re working in. NOTE:  For a comprehensive set of reference documents and tutorials for understanding and using curl, see its Tool Documentation page at https://curl.haxx.se/docs/tooldocs.html.

API Terms for the Parts of Your Request URL

As shown in the above curl call, the full request URL for this specific endpoint and method is:
https://apidocexample.com/swagger/classical/findByManufacturer?manufacturer=Ibanez
You can refer to the parts of this URL by the following terms:

  • Base Path: com
  • Path: /swagger/classical/findByManufacturer
  • Query: ?manufacturer=Ibanez

The Response Body

If successful, the server response will be an array object listing of all the classical guitars currently in the collection that are of the specified make (in this case, Ibanez).  Note that if (UI permitting) the user selects more than one classical guitar manufacturer to return, the array returned will list the guitars from all of the makes selected. In such a case, the query section of the request URL might look like the following:

  • ?make=Ibanez&make=Cordoba&make=Yamaha

The following section of code represents part of an array returned when the selected make is
simply Ibanez.

1         [

2            {

3               “id”: 00000001,

4               “manufacturer”: “Ibanez”,

5               “model”: “Ibanez GA3 6-String”,

6             “condition”: “Good”,

7               “price”: 119.99,

8               “color”: “Amber”,

9               “number of strings”: 6,

10           “material”: “Agathis wood”

11        }

12        {

13           “id”: 00000002,

14           “manufacturer”: “Ibanez”,

15           “model”: “Ibanez GA5TCE Classical Acoustic-Electric Guitar”,

16         “condition”: “Fair”,

17           “price”: 160.00,

18           “color”: “Spruce (tan)”,

19           “number of strings”: 6,

20           “material”: “Spruce/Mahogany”

21        }

22        {

23           “id”: 00000003,

24           “manufacturer”: “Ibanez”,

25           “model”: “Ibanez 315 Classical 1967”,

26         “condition”: “Good”,

27           “price”: 450.00,

28           “color”: “Amber”,

29           “number of strings”: 6,

30           “material”: “wood – unspecified”

31        }
.  .  .

32     ]