0

I am new to network programming and got started with boost, REST etc. I wanted to know if I could use REST API's with boost-asio such as using Google Maps' Distance Matrix in my program. But I couldn't find a proper documentation for boost.

I don't expect you to give me complete working code rather I need idea or some sort of guidance as to what to do, where to find things etc.Also this program will be in C++ purely (I don't know if it can even be done in C++, given this answer https://stackoverflow.com/a/28736632/4846740). Thanks

Note: This post was not very helpful Integrating Google maps with C++ Program

2 Answers2

0

You'd want to

  • use a REST library (e.g. cpprestsdk or some other frameworks like autobahn-cpp?), or = at least write the REST requests on top of a HTTP library, such as Boost Beast

The library examples show you everything you need to send requests and receive responses. If you want, you can use additional libraries like https://github.com/0xdead4ead/BeastHttp to make it even more high-level/instant.

sehe
  • 374,641
  • 47
  • 450
  • 633
-3

I would 100% recommend that you do not do this in C++. While I'm not a huge fan of Python, it's undoubtedly the hammer that is made for this nail. Check out BeautifulSoup, Mechanize, and Scrapy (+XPath), for really convenient ways of obtaining/parsing HTML, filling out web forms, and gaining responses. Typically, unless you're doing realtime target tracking, you do not need the latency gained from running everything in C/C++. You can get away with quarter-second, or even half-second updates.

I'm not sure what you're trying to do, but I would say save yourself the headache, and just work with Python.

Alex Baum
  • 166
  • 9
  • 1
    I concur 100% with the sentiment. As SO posts go, though, this is certainly more of a comment than an answer. – sehe Aug 31 '20 at 15:19
  • 1
    @sehe I agree. If I could comment I would have rather done that. – Alex Baum Aug 31 '20 at 19:15
  • This doesn't really address the Question. OP asked how it could do rest api with boost.asio, not what would be the best method for doing a program to communicate with a rest api. Also without knowing exactly what the OP use case is and their requirements, you can't make the claim that python will be a better choice. There are plenty of C++ rest api toolkits that are as easy to use as the python ones. – bone Feb 03 '22 at 17:17
  • @bone Claiming that anything C++ is as easy to use as Python doesn't sound right. There are lots of C++ rest api toolkits, but why, oh why, would you want to use C++ for something that is inherently not time-critical? – Alex Baum Feb 03 '22 at 22:00
  • You misunderstood what I wrote. I never said that "anything C++ is as easy to use as Python". I said "There are plenty of C++ rest api toolkits that are as easy to use as the python ones". Difference: What you thought I said: All of C++ rest libs are as easy as python. What I actually said: Plenty of (not all) C++ rest libs are as easy as python. And claimming that interacting with a rest API is not time critial is not true. Depending on the application and requirements, it might be. – bone Feb 06 '22 at 23:57