I have more than 2000 unittests/pytests in my project. Many of them ask API, but API can be lagged. Is there a way to expect APILagError in every single test and throw SKIP/XFAIL for any test if this error occurs?
Current:

test_1: ok
test_2: fail
test_3: ok

result: 1 fail, 2 ok => tests failed
Wanted:

test_1: ok
test_2: skip/xfail
test_3: ok

result: 2 ok, 1 skipped/xfailed => tests passed
I feel your pain. I'm going to do that annoying SO thing where I don't actually answer your question as you posed it, but suggest you change directions. You should choose one of:

mock that API so it doesn't time out any more and your tests aren't flakey
treat your API lag as normal behavior and increase the allowed duration of API calls so typical lag time doesn't result in a failed test
treat your API lag as a bug and go fix it so your tests pass 

Why are flakey tests bad?
Flakey tests mean you can't tell the difference between broken code and a slow API call. So your tests aren't helping you catch bugs. So what's the point?
Why would I ever mock the API? It's not "real"!
You'd do this if you want to test anything outside of the API. Decouple your logic from the API's behavior to eliminate flakiness and make your code more maintainable.
You might also be able to get a similarly-behaved but much faster API to test against as your mock. Like check out the API's code locally and populate it with a small set of data. Hit that in your tests instead of the production API. That would let you check its logic separate from its lagginess.
Allow failure for all tests if specific Error is thrown