If we look at the relationship between the scalar electric potential and electric field in electrostatics, $\vec{E} = - \vec{\nabla} \phi$, we can easily invert this relationship by $$ V (\vec{r}) = -\int \limits_{\vec{r}_0}^{\vec{r}} \mathrm{d} \vec{\ell} \cdot \vec{E} $$ where $\vec{r}_0$ is arbitrary.
This got me thinking; is the same possible for magnetic field $\vec{B} = \vec{\nabla} \times \vec{A}$? Can we find $\vec{A}$ (in some specific gauge) from $\vec{B}$ by inverting this relationship in terms of a line integral (I'm aware of finding $\vec{A}$ from current distribution, but that's a volume integral and it involves sources, which I'd like to avoid).
So I made a guess: $$ \vec{A} (\vec{r}) \overset{?}{=} \int \limits_{\vec{r}_0}^{\vec{r}} \mathrm{d} \vec{\ell} \times \vec{B} $$
Of course, we need to verify that this is correct (it isn't, but it's only a constant factor), which we can do $$ A_j \overset{?}{=} \varepsilon_{jab} \int \limits_{\vec{r}_0}^{\vec{r}} \mathrm{d} \ell_a B_b \quad \to \quad \left( \vec{\nabla} \times \vec{A} \right)_i = \varepsilon_{ikj} \partial_k A_j = \varepsilon_{ikj} \varepsilon_{jab} \partial_k \int \limits_{\vec{r}_0}^{\vec{r}} \mathrm{d} \ell_a B_b $$
I'm not so sure about this, but from what I understand, a derivative acting on a line integral like this will pluck out the index of the line element, $\mathrm{d} \ell$, in this case, $a$ becomes $k$ $$ \left( \vec{\nabla} \times \vec{A} \right)_i = \varepsilon_{ikj} \varepsilon_{jkb} B_b = \left( \delta_{ik} \delta_{kb} - \delta_{ib} \delta_{kk} \right) B_b = B_i - 3 B_i = - 2 B_i $$
So the correct formula would seem to be $$ \vec{A} (\vec{r}) \overset{\checkmark}{=} - \frac{1}{2} \int \limits_{\vec{r}_0}^{\vec{r}} \mathrm{d} \vec{\ell} \times \vec{B} $$
I verified that this should be the case on a simple magnetic field $\vec{B} = B_0 \hat{z}$ and for path that is a straight line between $\vec{r}_0 = \vec{0}$ and $\vec{r}$. In that case $\mathrm{d} \vec{\ell} = \hat{r} \mathrm{d} \ell$. We also need $\hat{r} \times \hat{z} = - \hat{\varphi}$ and the integral becomes $$ \vec{A} (\vec{r}) = \frac{1}{2} B_0 \hat{\varphi} \int \limits_0^r \mathrm{d} \ell = \frac{1}{2} B_0 r \hat{\varphi} = \frac{1}{2} B_0 \left( -y, x, 0 \right) $$
Taking a curl of this gives the original magnetic field.
An alternative way is to plug in $\vec{B} = \vec{\nabla} \times \vec{A}$ under the integral $$ \mathrm{d} \vec{\ell} \times \vec{B} = \mathrm{d} \vec{\ell} \times \left( \vec{\nabla} \times \vec{A} \right) = \vec{\nabla} \left( \mathrm{d} \vec{\ell} \cdot \vec{A} \right) - \left( \mathrm{d} \vec{\ell} \cdot \vec{\nabla} \right) \vec{A} $$
The problem is I am not sure what to do with the first term $\vec{\nabla} \left( \mathrm{d} \vec{\ell} \cdot \vec{A} \right)$, it doesn't seem to simplify to anything reasonable, whereas the second term $\left( \mathrm{d} \vec{\ell} \cdot \vec{\nabla} \right) \vec{A}$, when integrated, yields $\vec{A} (\vec{r}) - \vec{A} (\vec{r}_0)$. If my thoughts are correct though, the term $\mathrm{d} \ell_j \partial_i A_j$ should be equal to $- \mathrm{d} \ell_j \partial_j A_i$, i.e. the combination $\partial_i A_j + \partial_j A_i$ should be zero. I feel like this is rather a gauge choice than something that should always hold (although, it brings 6 equations, which seems like a lot for a gauge).
Can someone point me to the right direction? Is my formula correct? What about the $\partial_i A_j + \partial_j A_i = 0$?