• Что такое rest api простыми словами?

    HorrorInferno
    @HorrorInferno
    веб-разработчик, бэкэндер
    Если совсем простыми, то некий сервис даёт тебе доступ к своим данным, но не напрямую, а через оболочку, которая назвается REST API. Тебе даётся некий url, по которому ты можешь получить те самые данные. Как правило, при изменении параметров этого url, ты получаешь разные данные.
    Пример:
    Допустим ты берешь в качестве сервиса Википедию. Его специальный url, по которому ты можешь получить данные (его еще называют endpoint) выглядит так: https://en.wikipedia.org/w/api.php
    Допустим нам нужно найти какую-то краткую выдержку из вики по ключевым словам. Первым делом мы идем в документацию и смотрим, какие параметры нам для этого нужны. Для данной задачи нам потребуется url со следующими параметрами:
    https://en.wikipedia.org/w/api.php?action=opensearch&search=<search string>&prop=info&format=<format>&inprop=url


    search string - словосочетание, по которому мы хотим искать.
    format - формат в котором будет выдан ответ (самые популярные это json и xml)

    Пример обращения к WikiAPI:
    https://en.wikipedia.org/w/api.php?action=opensearch&search=microsoft&prop=info&format=json&inprop=url


    Ответ от WikiAPI:
    [
    "microsoft",
    [
    "Microsoft",
    "Microsoft Windows",
    "Microsoft Word",
    "Microsoft Excel",
    "Microsoft Office",
    "Microsoft Visual Studio",
    "Microsoft PowerPoint",
    "Microsoft SQL Server",
    "Microsoft Office 2007",
    "Microsoft Access"
    ],
    [
    "Microsoft Corporation (, abbreviated as MS) is an American multinational technology company with headquarters in Redmond, Washington.",
    "Microsoft Windows, or simply Windows, is a metafamily of graphical operating systems developed, marketed, and sold by Microsoft.",
    "Microsoft Word is a word processor developed by Microsoft. It was first released on October 25, 1983 under the name Multi-Tool Word for Xenix systems.",
    "Microsoft Excel is a spreadsheet developed by Microsoft for Windows, macOS, Android and iOS. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications.",
    "Microsoft Office is an office suite of applications, servers, and services developed by Microsoft. It was first announced by Bill Gates on 1 August 1988, at COMDEX in Las Vegas.",
    "Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs for Microsoft Windows, as well as web sites, web apps, web services and mobile apps.",
    "Microsoft PowerPoint is a presentation program, created by Robert Gaskins and Dennis Austin at a software company named Forethought, Inc.",
    "Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network (including the Internet).",
    "Microsoft Office 2007 (codenamed Office 12) is a version of Microsoft Office, a family of office suites and productivity software for Windows, developed and published by Microsoft.",
    "Microsoft Access is a database management system (DBMS) from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software-development tools."
    ],
    [
    "https://en.wikipedia.org/wiki/Microsoft",
    "https://en.wikipedia.org/wiki/Microsoft_Windows",
    "https://en.wikipedia.org/wiki/Microsoft_Word",
    "https://en.wikipedia.org/wiki/Microsoft_Excel",
    "https://en.wikipedia.org/wiki/Microsoft_Office",
    "https://en.wikipedia.org/wiki/Microsoft_Visual_Studio",
    "https://en.wikipedia.org/wiki/Microsoft_PowerPoint",
    "https://en.wikipedia.org/wiki/Microsoft_SQL_Server",
    "https://en.wikipedia.org/wiki/Microsoft_Office_2007",
    "https://en.wikipedia.org/wiki/Microsoft_Access"
    ]
    ]
    Ответ написан
    2 комментария