locked
Need some help with api usage RRS feed

  • Question

  • User1253338400 posted
    Hi
    Is there some document or eeading material that can explain why api and rest api was developed. Why were they required and what limitations were faced prior to them.
    I would like to understand more

    Thanks

    Friday, January 19, 2018 11:47 AM

Answers

All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 19, 2018 4:46 PM
  • User1253338400 posted

    Hi,

    So after reading that if I break it down by the following.

    Lets say I have a company ACME and it provides finding books in a library at certain Universities.

    I would write the API (which queries tha database for the required Uni and gets the book . Could be search by catergory , title or other factors)

    Then I make this API publicly available and any user can query the API and retrieve the result set. 

    Is that what it is in a nutshell ?

    Thanks

    Saturday, January 20, 2018 3:37 AM
  • User-1664597257 posted

    The original paper about RESTFUL APIs was written by Roy Fieldings and discussion is centered around resources that a consumer can request from RESTFUL APIs. REST APIs are not concerned with the data store it can be anything.

    APIs (REST or otherwise) are not necessarily publicly available, APIs can be secured and have restricted access.

    Saturday, January 20, 2018 6:35 PM
  • User-832373396 posted

    <g class="gr_ gr_24 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="24" data-gr-id="24">Hi</g> <g class="gr_ gr_8 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="8" data-gr-id="8">robby</g>,

    I would like to understand more

    Sir, please refer to this example:

    Get Books By Author

    To get a list of <g class="gr_ gr_65 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="65" data-gr-id="65">a books</g> for a particular author, the client will send a GET request <g class="gr_ gr_66 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="66" data-gr-id="66">to</g><g class="gr_ gr_66 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="66" data-gr-id="66"> </g>/api/authors/id/books<g class="gr_ gr_66 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="66" data-gr-id="66">,</g> where <g class="gr_ gr_59 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="59" data-gr-id="59">id</g> is the ID of the author.

    Add the following method <g class="gr_ gr_62 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="62" data-gr-id="62"><g class="gr_ gr_60 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="60" data-gr-id="60">to</g></g><g class="gr_ gr_62 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="62" data-gr-id="62"> </g>BooksController<g class="gr_ gr_62 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="62" data-gr-id="62">.</g>

    [Route("~/api/authors/{authorId:int}/books")]
    public IQueryable<BookDto> GetBooksByAuthor(int authorId)
    {
        return db.Books.Include(b => b.Author)
            .Where(b => b.AuthorId == authorId)
            .Select(AsBookDto);
    }
    

    This example is interesting because "books" is treated a child resource of "authors". This pattern is quite common in RESTful APIs.

    From  https://docs.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api 

    Guidehttps://www.asp.net/web-api/overview/resources 

    http://codebetter.com/howarddierking/2012/11/09/versioning-restful-services/ 

    With regards, Angelina Jolie

    Monday, January 22, 2018 7:56 AM