asp.net web api - how to implement Complex Web API queries in ASP Core -


i'm new web api design, i've tried learn best practices of web api design using these articles:

1.microsoft rest api guidelines

2.web api design-crafting interfaces developers love "apigee"

apigee recommending web api developers use these recommendations have better apis. quote here 2 of recommendations: need c# code implementing these recommendations in web apis (in asp core) back-end native mobile apps , angularjs web site.

  1. sweep complexity behind ‘?’ apis have intricacies beyond base level of resource. complexities can include many states can updated, changed, queried, attributes associated resource.

make simple developers use base url putting optional states , attributes behind http question mark. red dogs running in park:

get /dogs?color=red&state=running&location=park

  1. partial response allows give developers information need.

take example request tweet on twitter api. you'll more typical twitter app needs - including name of person, text of tweet, timestamp, how message re-tweeted, , lot of metadata.

let's @ how several leading apis handle giving developers need in responses, including google pioneered idea of partial response.

linkedin

/people:(id,first-name,last-name,industry)

this request on person returns id, first name, last name, , industry.

linkedin partial selection using terse :(...) syntax isn't self-evident.

plus it's difficult developer reverse engineer meaning using search engine.

facebook

/joe.smith/friends?fields=id,name,picture

google

?fields=title,media:group(media:thumbnail)

google , facebook have similar approach, works well.

they each have optional parameter called fields after put names of fieldsyou want returned.

as see in example, can put sub-objects in responses pull in other information additional resources.

add optional fields in comma-delimited list

the google approach works extremely well.

here's how information need our dogs api using approach:

/dogs?fields=name,color,location

now need c# code handles these kind of queries or more complex this:

api/books/?publisher=jat&writer=tom&location=la?fields=title,isbn?$orderby=location desc,writerlimit=25&offset=50

so web api users able send kind of requests want different complexities, fields, ordering,... based on needs.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -