How To Call An API in C# – Examples, Best Practices, Memory Management, and Pitfalls



It seems like everything has an API these days but have you ever wondered how to make use of an API in your application? It turns out that it isn’t really that hard at all. In this video, I am going to show you how to easily load the data from two different APIs into an application. Along the way, I will show you how to avoid some memory issues and other best practices around talking to APIs

Full courses: https://www.iamtimcorey.com/
Source Code: https://leadmagnets.app/?Resource=CallAnApiInCSharp
Patreon: https://patreon.com/IAmTimCorey
Newsletter signup: https://signup.iamtimcorey.com/

0:00 – Intro
1:00 – Demo application walk-through
4:09 – Setting up API calling: WebApi.Client and Newtonsoft.json NuGet references
6:02 – Setting up API calling: HttpClient
13:48 – Setting up API calling: API calls
19:14 – Setting up API calling: Reading and working with json data
28:18 – Loading image in WPF (form a website)
35:29 – Adding events in WPF application: wiring up action buttons
39:40 – Note on information Cashing
42:55 – Sunrise-sunset API: Nested json objects, API calls, WPF events, displaying information
51:56 – Loading other WPF forms from MainWindow
53:38 – Summary and concluding remarks

Chapter breakdown by Ralfs HBK

Comments are closed.