I am looking for a (preferably Open Source) API usable in C/C++, that enables one to send/receive data over the Tor network. So I want to build an application that uses sockets to communicate data over a network, but I want that data to be sent over the Tor network instead. Is that possible? Is there a API for it?
I don't think there are any well-supported C APIs. There are generally two options for accessing Tor through an API. You can communicate to a separate Tor process using the Tor control protocol and SOCKS port, or you can statically link tor into your program (for example iCepa for iOS). If you're more specific about what your requirements are, you might get more help.– SteveMay 3, 2021 at 23:51
So I want to build an application that uses sockets to communicate data over a network, but I want that data to be sent over the Tor network instead.
You could enable socks5 proxy in your
/etc/tor/torrc tor's config:
Now, simply open your socket to this port, tell socks5 proxy what you want. Ssl/no-ssl, which site/ip-address/.onion domain to get, auth/no-auth, etcetera... So, your task renamed/reshaped from
"How to C/Api Tor" to
"how to pass request via socks5 proxy on C/C++ language" which is much more older and easiest task in the world. And of-course there are thousands of code snippets over the network and stack-overflow, which are doing this on all languages in all possible ways.